Python 3 compatibility after rebase
This commit is contained in:
parent
8a9465f4d1
commit
082e1f3e53
|
@ -84,7 +84,7 @@ _ldap_module_lock = LDAPLock(desc='Module wide')
|
|||
|
||||
from ldap.functions import open,initialize,init,get_option,set_option,escape_str
|
||||
|
||||
from ldapobject import NO_UNIQUE_ENTRY
|
||||
from ldap.ldapobject import NO_UNIQUE_ENTRY
|
||||
|
||||
from ldap.dn import explode_dn,explode_rdn,str2dn,dn2str
|
||||
del str2dn
|
||||
|
|
|
@ -576,7 +576,7 @@ if __name__ == '__main__':
|
|||
parser_method()
|
||||
end_time = time.time()
|
||||
input_file.close()
|
||||
print '***Time needed:',end_time-start_time,'seconds'
|
||||
print '***Records read:',ldif_parser.records_read
|
||||
print '***Lines read:',ldif_parser.line_counter
|
||||
print '***Bytes read:',ldif_parser.byte_counter,'of',input_file_size
|
||||
print('***Time needed:',end_time-start_time,'seconds')
|
||||
print('***Records read:',ldif_parser.records_read)
|
||||
print('***Lines read:',ldif_parser.line_counter)
|
||||
print('***Bytes read:',ldif_parser.byte_counter,'of',input_file_size)
|
||||
|
|
|
@ -664,10 +664,10 @@ l_ldap_sasl_bind_s( LDAPObject* self, PyObject* args )
|
|||
|
||||
if (ldaperror == LDAP_SASL_BIND_IN_PROGRESS) {
|
||||
if (servercred && servercred->bv_val && *servercred->bv_val)
|
||||
return PyString_FromStringAndSize( servercred->bv_val, servercred->bv_len );
|
||||
return PyBytes_FromStringAndSize( servercred->bv_val, servercred->bv_len );
|
||||
} else if (ldaperror != LDAP_SUCCESS)
|
||||
return LDAPerror( self->ldap, "l_ldap_sasl_bind_s" );
|
||||
return PyInt_FromLong( ldaperror );
|
||||
return PyLong_FromLong( ldaperror );
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
|
|
|
@ -40,6 +40,7 @@ void LDAPadd_methods( PyObject*d, PyMethodDef*methods );
|
|||
#define PyBytes_Check PyString_Check
|
||||
#define PyBytes_Size PyString_Size
|
||||
#define PyBytes_AsString PyString_AsString
|
||||
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
#endif
|
||||
|
||||
#endif /* __h_common_ */
|
||||
|
|
|
@ -69,7 +69,6 @@ Tuple_to_LDAPControl( PyObject* tup )
|
|||
char iscritical;
|
||||
struct berval berbytes;
|
||||
PyObject *bytes;
|
||||
PyObject *bytes_utf8;
|
||||
LDAPControl *lc = NULL;
|
||||
Py_ssize_t len;
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ testcases_split_tokens = (
|
|||
for t,r in testcases_split_tokens:
|
||||
l = ldap.schema.tokenizer.split_tokens(t,{'MUST':None})
|
||||
if l!=r:
|
||||
print 'String:',repr(t)
|
||||
print '=>',l
|
||||
print 'differs from',r
|
||||
print('String:',repr(t))
|
||||
print('=>',l)
|
||||
print('differs from',r)
|
||||
|
|
|
@ -6,7 +6,7 @@ import ldap
|
|||
|
||||
from ldap.modlist import addModlist,modifyModlist
|
||||
|
||||
print '\nTesting function addModlist():'
|
||||
print('\nTesting function addModlist():')
|
||||
addModlist_tests = [
|
||||
(
|
||||
{
|
||||
|
@ -31,11 +31,11 @@ for entry,test_modlist in addModlist_tests:
|
|||
result_modlist = addModlist(entry)
|
||||
result_modlist.sort()
|
||||
if test_modlist!=result_modlist:
|
||||
print 'addModlist(%s) returns\n%s\ninstead of\n%s.' % (
|
||||
print('addModlist(%s) returns\n%s\ninstead of\n%s.' % (
|
||||
repr(entry),repr(result_modlist),repr(test_modlist)
|
||||
)
|
||||
))
|
||||
|
||||
print '\nTesting function modifyModlist():'
|
||||
print('\nTesting function modifyModlist():')
|
||||
modifyModlist_tests = [
|
||||
|
||||
(
|
||||
|
@ -129,9 +129,9 @@ for old_entry,new_entry,case_ignore_attr_types,test_modlist in modifyModlist_tes
|
|||
result_modlist.sort()
|
||||
|
||||
if test_modlist!=result_modlist:
|
||||
print 'modifyModlist(%s,%s) returns\n%s\ninstead of\n%s.' % (
|
||||
print('modifyModlist(%s,%s) returns\n%s\ninstead of\n%s.' % (
|
||||
repr(old_entry),
|
||||
repr(new_entry),
|
||||
repr(result_modlist),
|
||||
repr(test_modlist)
|
||||
)
|
||||
))
|
||||
|
|
|
@ -5,7 +5,7 @@ Performes various tests for module ldapurl
|
|||
import ldapurl
|
||||
from ldapurl import *
|
||||
|
||||
print '\nTesting function isLDAPUrl():'
|
||||
print('\nTesting function isLDAPUrl():')
|
||||
is_ldap_url_tests = {
|
||||
# Examples from RFC2255
|
||||
'ldap:///o=University%20of%20Michigan,c=US':1,
|
||||
|
@ -28,11 +28,11 @@ is_ldap_url_tests = {
|
|||
for ldap_url in is_ldap_url_tests.keys():
|
||||
result_is_ldap_url = isLDAPUrl(ldap_url)
|
||||
if result_is_ldap_url !=is_ldap_url_tests[ldap_url]:
|
||||
print 'isLDAPUrl("%s") returns %d instead of %d.' % (
|
||||
print('isLDAPUrl("%s") returns %d instead of %d.' % (
|
||||
repr(ldap_url),result_is_ldap_url,is_ldap_url_tests[ldap_url]
|
||||
)
|
||||
))
|
||||
|
||||
print '\nTesting class LDAPUrl:'
|
||||
print('\nTesting class LDAPUrl:')
|
||||
parse_ldap_url_tests = [
|
||||
(
|
||||
'ldap://root.openldap.org/dc=openldap,dc=org',
|
||||
|
@ -130,25 +130,25 @@ parse_ldap_url_tests = [
|
|||
for ldap_url_str,test_ldap_url_obj in parse_ldap_url_tests:
|
||||
# print '\nTesting LDAP URL:',repr(ldap_url)
|
||||
ldap_url_obj = LDAPUrl(ldapUrl=ldap_url_str)
|
||||
print '#'*72
|
||||
print test_ldap_url_obj.unparse()
|
||||
print('#'*72)
|
||||
print(test_ldap_url_obj.unparse())
|
||||
if ldap_url_obj.__ne__(test_ldap_url_obj):
|
||||
print '-'*72
|
||||
print 'Parsing error! Attributes of LDAPUrl(%s) are:\n%s\ninstead of:\n%s' % (
|
||||
print('-'*72)
|
||||
print('Parsing error! Attributes of LDAPUrl(%s) are:\n%s\ninstead of:\n%s' % (
|
||||
repr(ldap_url_str),
|
||||
repr(ldap_url_obj),
|
||||
repr(test_ldap_url_obj)
|
||||
)
|
||||
))
|
||||
else:
|
||||
print 'Parsing ok'
|
||||
print('Parsing ok')
|
||||
unparsed_ldap_url_str = test_ldap_url_obj.unparse()
|
||||
unparsed_ldap_url_obj = LDAPUrl(ldapUrl=unparsed_ldap_url_str)
|
||||
if unparsed_ldap_url_obj.__ne__(test_ldap_url_obj):
|
||||
print '-'*72
|
||||
print 'Unparsing error! Attributes of LDAPUrl(%s) are:\n%s\ninstead of:\n%s' % (
|
||||
print('-'*72)
|
||||
print('Unparsing error! Attributes of LDAPUrl(%s) are:\n%s\ninstead of:\n%s' % (
|
||||
repr(unparsed_ldap_url_str),
|
||||
repr(unparsed_ldap_url_obj),
|
||||
repr(test_ldap_url_obj)
|
||||
)
|
||||
))
|
||||
else:
|
||||
print 'Unparsing ok'
|
||||
print('Unparsing ok')
|
||||
|
|
|
@ -17,7 +17,7 @@ class MyLDAPUrl(LDAPUrl):
|
|||
ldap_url = MyLDAPUrl(sys.argv[1])
|
||||
trace_level = int(ldap_url.trace_level or '0')
|
||||
|
||||
print '***trace_level',trace_level
|
||||
print('***trace_level',trace_level)
|
||||
|
||||
ldap.trace_level = trace_level
|
||||
|
||||
|
@ -39,6 +39,6 @@ result = l.search_s(
|
|||
|
||||
pprint.pprint(result)
|
||||
|
||||
print '***DIAGNOSTIC_MESSAGE',repr(l.get_option(ldap.OPT_DIAGNOSTIC_MESSAGE))
|
||||
print('***DIAGNOSTIC_MESSAGE',repr(l.get_option(ldap.OPT_DIAGNOSTIC_MESSAGE)))
|
||||
|
||||
l.unbind_s()
|
||||
|
|
|
@ -377,7 +377,7 @@ if __name__ == '__main__' and sys.argv == ['run']:
|
|||
slapd.start()
|
||||
print("Contents of LDAP server follow:\n")
|
||||
for dn,attrs in slapd.ldapsearch():
|
||||
print("dn: " + dn)
|
||||
print(("dn: " + dn))
|
||||
for name,val in attrs:
|
||||
print(name + ": " + val)
|
||||
print("")
|
||||
|
|
Loading…
Reference in New Issue