<86>Jan 13 00:52:06 userdel[40691]: delete user 'rooter' <86>Jan 13 00:52:06 userdel[40691]: removed group 'rooter' owned by 'rooter' <86>Jan 13 00:52:06 groupadd[40714]: group added to /etc/group: name=rooter, GID=681 <86>Jan 13 00:52:06 groupadd[40714]: group added to /etc/gshadow: name=rooter <86>Jan 13 00:52:06 groupadd[40714]: new group: name=rooter, GID=681 <86>Jan 13 00:52:06 useradd[40742]: new user: name=rooter, UID=681, GID=681, home=/root, shell=/bin/bash <86>Jan 13 00:52:06 userdel[40883]: delete user 'builder' <86>Jan 13 00:52:06 userdel[40883]: removed group 'builder' owned by 'builder' <86>Jan 13 00:52:06 userdel[40883]: removed shadow group 'builder' owned by 'builder' <86>Jan 13 00:52:06 groupadd[40899]: group added to /etc/group: name=builder, GID=682 <86>Jan 13 00:52:06 groupadd[40899]: group added to /etc/gshadow: name=builder <86>Jan 13 00:52:06 groupadd[40899]: new group: name=builder, GID=682 <86>Jan 13 00:52:06 useradd[40908]: new user: name=builder, UID=682, GID=682, home=/usr/src, shell=/bin/bash <13>Jan 13 00:52:09 rpmi: libcom_err-1.42.13-alt2 1449075846 installed <13>Jan 13 00:52:09 rpmi: libverto-0.2.6-alt1_6 1455633234 installed <13>Jan 13 00:52:09 rpmi: libgdbm-1.8.3-alt10 1454943313 installed <13>Jan 13 00:52:09 rpmi: libverto-devel-0.2.6-alt1_6 1455633234 installed <13>Jan 13 00:52:09 rpmi: libcom_err-devel-1.42.13-alt2 1449075846 installed <13>Jan 13 00:52:09 rpmi: libtinfo-devel-5.9-alt8 1456756459 installed <13>Jan 13 00:52:09 rpmi: libncurses-devel-5.9-alt8 1456756459 installed <13>Jan 13 00:52:09 rpmi: libkeyutils-1.5.10-alt0.M80P.1 1490025499 installed <13>Jan 13 00:52:09 rpmi: libexpat-2.2.4-alt0.M80P.1 1503871120 installed <13>Jan 13 00:52:09 rpmi: ca-certificates-2016.02.25-alt1 1462368370 installed <13>Jan 13 00:52:09 rpmi: libcrypto10-1.0.2n-alt0.M80P.1 1512766129 installed <13>Jan 13 00:52:09 rpmi: libssl10-1.0.2n-alt0.M80P.1 1512766129 installed <86>Jan 13 00:52:09 groupadd[50794]: group added to /etc/group: name=_keytab, GID=499 <86>Jan 13 00:52:09 groupadd[50794]: group added to /etc/gshadow: name=_keytab <86>Jan 13 00:52:09 groupadd[50794]: new group: name=_keytab, GID=499 <13>Jan 13 00:52:09 rpmi: libkrb5-1.14.6-alt1.M80P.1 1525355673 installed <86>Jan 13 00:52:09 groupadd[50960]: group added to /etc/group: name=sasl, GID=498 <86>Jan 13 00:52:09 groupadd[50960]: group added to /etc/gshadow: name=sasl <86>Jan 13 00:52:09 groupadd[50960]: new group: name=sasl, GID=498 <13>Jan 13 00:52:09 rpmi: libsasl2-3-2.1.26-alt7 1479477445 installed <13>Jan 13 00:52:09 rpmi: libldap-2.4.45-alt1.M80P.1 1513980376 installed <13>Jan 13 00:52:09 rpmi: libkrb5-ldap-1.14.6-alt1.M80P.1 1525355673 installed <13>Jan 13 00:52:09 rpmi: libkrb5-devel-1.14.6-alt1.M80P.1 1525355673 installed <13>Jan 13 00:52:09 rpmi: libssl-devel-1.0.2n-alt0.M80P.1 1512766129 installed <13>Jan 13 00:52:09 rpmi: libldap-devel-2.4.45-alt1.M80P.1 1513980376 installed <13>Jan 13 00:52:09 rpmi: libsasl2-devel-2.1.26-alt7 1479477445 installed <13>Jan 13 00:52:10 rpmi: python3-base-3.5.4-alt2.M80P.1 1527753911 installed <13>Jan 13 00:52:10 rpmi: python3-3.5.4-alt2.M80P.1 1527753911 installed <13>Jan 13 00:52:10 rpmi: rpm-build-python3-0.1.10.10-alt1.M80P.1 1530521451 installed <13>Jan 13 00:52:10 rpmi: libpython3-3.5.4-alt2.M80P.1 1527753911 installed <13>Jan 13 00:52:10 rpmi: python-modules-encodings-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python3-dev-3.5.4-alt2.M80P.1 1527753911 installed <13>Jan 13 00:52:11 rpmi: python-modules-compiler-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-email-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-ctypes-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-multiprocessing-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-logging-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-modules-unittest-2.7.11-alt6.M80P.1 1527682470 installed <13>Jan 13 00:52:11 rpmi: python-tools-2to3-2.7.11-alt6.M80P.1 1527682470 installed Installing python3-module-ldap-2.3.13-alt1.1.src.rpm Building target platforms: x86_64 Building for target x86_64 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.80246 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf python-ldap-2.3.13 + echo 'Source #0 (python-ldap-2.3.13.tar):' Source #0 (python-ldap-2.3.13.tar): + /bin/tar -xf /usr/src/RPM/SOURCES/python-ldap-2.3.13.tar + cd python-ldap-2.3.13 + /bin/chmod -c -Rf u+rwX,go-w . + find -type f -name '*.py' -exec 2to3 -w -n '{}' + RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ./setup.py RefactoringTool: Refactored ./Tests/t_search.py RefactoringTool: Refactored ./Tests/t_ldapurl.py --- ./setup.py (original) +++ ./setup.py (refactored) @@ -13,8 +13,9 @@ except ImportError: from distutils.core import setup, Extension -from ConfigParser import ConfigParser +from configparser import ConfigParser import sys,os,string,time +from functools import reduce ################################################################## # Weird Hack to grab release version of python-ldap from local dir @@ -50,7 +51,7 @@ if cfg.has_section('_ldap'): for name in dir(LDAP_CLASS): if cfg.has_option('_ldap', name): - print name + ': ' + cfg.get('_ldap', name) + print(name + ': ' + cfg.get('_ldap', name)) setattr(LDAP_CLASS, name, cfg.get('_ldap', name).split()) for i in range(len(LDAP_CLASS.defines)): --- ./Tests/t_search.py (original) +++ ./Tests/t_search.py (refactored) @@ -52,7 +52,7 @@ result = l.search_s(base, ldap.SCOPE_SUBTREE, '(cn=Foo*)', ['*']) result.sort() - self.assertEquals(result, + self.assertEqual(result, [('cn=Foo1,'+base, {'cn': ['Foo1'], 'objectClass': ['organizationalRole']}), ('cn=Foo2,'+base, @@ -70,7 +70,7 @@ result = l.search_s(base, ldap.SCOPE_ONELEVEL, '(cn=Foo*)', ['*']) result.sort() - self.assertEquals(result, + self.assertEqual(result, [('cn=Foo1,'+base, {'cn': ['Foo1'], 'objectClass': ['organizationalRole']}), ('cn=Foo2,'+base, @@ -86,7 +86,7 @@ result = l.search_s(base, ldap.SCOPE_SUBTREE, '(cn=Foo4)', ['cn']) result.sort() - self.assertEquals(result, + self.assertEqual(result, [('cn=Foo4,ou=Container,'+base, {'cn': ['Foo4']})] ) --- ./Tests/t_ldapurl.py (original) +++ ./Tests/t_ldapurl.py (refactored) @@ -1,5 +1,5 @@ import ldap, unittest -import urllib +import urllib.request, urllib.parse, urllib.error from ldapurl import LDAPUrl @@ -20,40 +20,40 @@ class TestLDAPUrl(unittest.TestCase): def assertNone(self, expr, msg=None): - self.failIf(expr is not None, msg or ("%r" % expr)) + self.assertFalse(expr is not None, msg or ("%r" % expr)) def test_combo(self): u = MyLDAPUrl("ldap://127.0.0.1:1234/dc=example,dc=com" + "?attr1,attr2,attr3" + "?sub" - + "?" + urllib.quote("(objectClass=*)") - + "?bindname=" + urllib.quote("cn=d,c=au") - + ",X-BINDPW=" + urllib.quote("???") + + "?" + urllib.parse.quote("(objectClass=*)") + + "?bindname=" + urllib.parse.quote("cn=d,c=au") + + ",X-BINDPW=" + urllib.parse.quote("???") + ",trace=8" ) - self.assertEquals(u.urlscheme, "ldap") - self.assertEquals(u.hostport, "127.0.0.1:1234") - self.assertEquals(u.dn, "dc=example,dc=com") - self.assertEquals(u.attrs, ["attr1","attr2","attr3"]) - self.assertEquals(u.scope, ldap.SCOPE_SUBTREE) - self.assertEquals(u.filterstr, "(objectClass=*)") - self.assertEquals(len(u.extensions), 3) - self.assertEquals(u.who, "cn=d,c=au") - self.assertEquals(u.cred, "???") - self.assertEquals(u.trace_level, "8") + self.assertEqual(u.urlscheme, "ldap") + self.assertEqual(u.hostport, "127.0.0.1:1234") + self.assertEqual(u.dn, "dc=example,dc=com") + self.assertEqual(u.attrs, ["attr1","attr2","attr3"]) + self.assertEqual(u.scope, ldap.SCOPE_SUBTREE) + self.assertEqual(u.filterstr, "(objectClass=*)") + self.assertEqual(len(u.extensions), 3) + self.assertEqual(u.who, "cn=d,c=au") + self.assertEqual(u.cred, "???") + self.assertEqual(u.trace_level, "8") def test_parse_default_hostport(self): u = LDAPUrl("ldap://") - self.assertEquals(u.urlscheme, "ldap") - self.assertEquals(u.hostport, "") + self.assertEqual(u.urlscheme, "ldap") + self.assertEqual(u.hostport, "") def test_parse_empty_dn(self): u = LDAPUrl("ldap://") - self.assertEquals(u.dn, "") + self.assertEqual(u.dn, "") u = LDAPUrl("ldap:///") - self.assertEquals(u.dn, "") + self.assertEqual(u.dn, "") u = LDAPUrl("ldap:///?") - self.assertEquals(u.dn, "") + self.assertEqual(u.dn, "") def test_parse_default_attrs(self): u = LDAPUrl("ldap://") @@ -69,71 +69,71 @@ def test_parse_default_extensions(self): u = LDAPUrl("ldap://") - self.assertEquals(len(u.extensions), 0) + self.assertEqual(len(u.extensions), 0) def test_parse_schemes(self): u = LDAPUrl("ldap://") - self.assertEquals(u.urlscheme, "ldap") + self.assertEqual(u.urlscheme, "ldap") u = LDAPUrl("ldapi://") - self.assertEquals(u.urlscheme, "ldapi") + self.assertEqual(u.urlscheme, "ldapi") u = LDAPUrl("ldaps://") - self.assertEquals(u.urlscheme, "ldaps") + self.assertEqual(u.urlscheme, "ldaps") def test_parse_hostport(self): u = LDAPUrl("ldap://a") - self.assertEquals(u.hostport, "a") + self.assertEqual(u.hostport, "a") u = LDAPUrl("ldap://a.b") - self.assertEquals(u.hostport, "a.b") + self.assertEqual(u.hostport, "a.b") u = LDAPUrl("ldap://a.") - self.assertEquals(u.hostport, "a.") + self.assertEqual(u.hostport, "a.") u = LDAPUrl("ldap://%61%62:%32/") - self.assertEquals(u.hostport, "ab:2") + self.assertEqual(u.hostport, "ab:2") u = LDAPUrl("ldap://[::1]/") - self.assertEquals(u.hostport, "[::1]") + self.assertEqual(u.hostport, "[::1]") u = LDAPUrl("ldap://[::1]") - self.assertEquals(u.hostport, "[::1]") + self.assertEqual(u.hostport, "[::1]") u = LDAPUrl("ldap://[::1]:123/") - self.assertEquals(u.hostport, "[::1]:123") + self.assertEqual(u.hostport, "[::1]:123") u = LDAPUrl("ldap://[::1]:123") - self.assertEquals(u.hostport, "[::1]:123") + self.assertEqual(u.hostport, "[::1]:123") def test_parse_dn(self): u = LDAPUrl("ldap:///") - self.assertEquals(u.dn, "") + self.assertEqual(u.dn, "") u = LDAPUrl("ldap:///dn=foo") - self.assertEquals(u.dn, "dn=foo") + self.assertEqual(u.dn, "dn=foo") u = LDAPUrl("ldap:///dn=foo%2cdc=bar") - self.assertEquals(u.dn, "dn=foo,dc=bar") + self.assertEqual(u.dn, "dn=foo,dc=bar") u = LDAPUrl("ldap:///dn=foo%20bar") - self.assertEquals(u.dn, "dn=foo bar") + self.assertEqual(u.dn, "dn=foo bar") u = LDAPUrl("ldap:///dn=foo%2fbar") - self.assertEquals(u.dn, "dn=foo/bar") + self.assertEqual(u.dn, "dn=foo/bar") u = LDAPUrl("ldap:///dn=foo%2fbar?") - self.assertEquals(u.dn, "dn=foo/bar") + self.assertEqual(u.dn, "dn=foo/bar") u = LDAPUrl("ldap:///dn=foo%3f?") - self.assertEquals(u.dn, "dn=foo?") + self.assertEqual(u.dn, "dn=foo?") u = LDAPUrl("ldap:///dn=foo%3f") - self.assertEquals(u.dn, "dn=foo?") + self.assertEqual(u.dn, "dn=foo?") u = LDAPUrl("ldap:///dn=str%c3%b6der.com") - self.assertEquals(u.dn, "dn=str\xc3\xb6der.com") + self.assertEqual(u.dn, "dn=str\xc3\xb6der.com") def test_parse_attrs(self): u = LDAPUrl("ldap:///?") - self.assertEquals(u.attrs, None) + self.assertEqual(u.attrs, None) u = LDAPUrl("ldap:///??") - self.assertEquals(u.attrs, None) + self.assertEqual(u.attrs, None) u = LDAPUrl("ldap:///?*?") - self.assertEquals(u.attrs, ['*']) + self.assertEqual(u.attrs, ['*']) u = LDAPUrl("ldap:///?*,*?") - self.assertEquals(u.attrs, ['*','*']) + self.assertEqual(u.attrs, ['*','*']) u = LDAPUrl("ldap:///?a") - self.assertEquals(u.attrs, ['a']) + self.assertEqual(u.attrs, ['a']) u = LDAPUrl("ldap:///?%61") - self.assertEquals(u.attrs, ['a']) + self.assertEqual(u.attrs, ['a']) u = LDAPUrl("ldap:///?a,b") - self.assertEquals(u.attrs, ['a','b']) + self.assertEqual(u.attrs, ['a','b']) u = LDAPUrl("ldap:///?a%3fb") - self.assertEquals(u.attrs, ['a?b']) + self.assertEqual(u.attrs, ['a?b']) def test_parse_scope_default(self): u = LDAPUrl("ldap:///??") @@ -143,73 +143,73 @@ def test_parse_scope(self): u = LDAPUrl("ldap:///??sub") - self.assertEquals(u.scope, ldap.SCOPE_SUBTREE) + self.assertEqual(u.scope, ldap.SCOPE_SUBTREE) u = LDAPUrl("ldap:///??sub?") - self.assertEquals(u.scope, ldap.SCOPE_SUBTREE) + self.assertEqual(u.scope, ldap.SCOPE_SUBTREE) u = LDAPUrl("ldap:///??base") - self.assertEquals(u.scope, ldap.SCOPE_BASE) + self.assertEqual(u.scope, ldap.SCOPE_BASE) u = LDAPUrl("ldap:///??base?") - self.assertEquals(u.scope, ldap.SCOPE_BASE) + self.assertEqual(u.scope, ldap.SCOPE_BASE) u = LDAPUrl("ldap:///??one") - self.assertEquals(u.scope, ldap.SCOPE_ONELEVEL) + self.assertEqual(u.scope, ldap.SCOPE_ONELEVEL) u = LDAPUrl("ldap:///??one?") - self.assertEquals(u.scope, ldap.SCOPE_ONELEVEL) + self.assertEqual(u.scope, ldap.SCOPE_ONELEVEL) def test_parse_filter(self): u = LDAPUrl("ldap:///???(cn=Bob)") - self.assertEquals(u.filterstr, "(cn=Bob)") + self.assertEqual(u.filterstr, "(cn=Bob)") u = LDAPUrl("ldap:///???(cn=Bob)?") - self.assertEquals(u.filterstr, "(cn=Bob)") + self.assertEqual(u.filterstr, "(cn=Bob)") u = LDAPUrl("ldap:///???(cn=Bob%20Smith)?") - self.assertEquals(u.filterstr, "(cn=Bob Smith)") + self.assertEqual(u.filterstr, "(cn=Bob Smith)") u = LDAPUrl("ldap:///???(cn=Bob/Smith)?") - self.assertEquals(u.filterstr, "(cn=Bob/Smith)") + self.assertEqual(u.filterstr, "(cn=Bob/Smith)") u = LDAPUrl("ldap:///???(cn=Bob:Smith)?") - self.assertEquals(u.filterstr, "(cn=Bob:Smith)") + self.assertEqual(u.filterstr, "(cn=Bob:Smith)") u = LDAPUrl("ldap:///???&(cn=Bob)(objectClass=user)?") - self.assertEquals(u.filterstr, "&(cn=Bob)(objectClass=user)") + self.assertEqual(u.filterstr, "&(cn=Bob)(objectClass=user)") u = LDAPUrl("ldap:///???|(cn=Bob)(objectClass=user)?") - self.assertEquals(u.filterstr, "|(cn=Bob)(objectClass=user)") + self.assertEqual(u.filterstr, "|(cn=Bob)(objectClass=user)") u = LDAPUrl("ldap:///???(cn=Q%3f)?") - self.assertEquals(u.filterstr, "(cn=Q?)") + self.assertEqual(u.filterstr, "(cn=Q?)") u = LDAPUrl("ldap:///???(cn=Q%3f)") - self.assertEquals(u.filterstr, "(cn=Q?)") + self.assertEqual(u.filterstr, "(cn=Q?)") u = LDAPUrl("ldap:///???(sn=Str%c3%b6der)") # (possibly bad?) - self.assertEquals(u.filterstr, "(sn=Str\xc3\xb6der)") + self.assertEqual(u.filterstr, "(sn=Str\xc3\xb6der)") u = LDAPUrl("ldap:///???(sn=Str\\c3\\b6der)") - self.assertEquals(u.filterstr, "(sn=Str\\c3\\b6der)") # (recommended) + self.assertEqual(u.filterstr, "(sn=Str\\c3\\b6der)") # (recommended) u = LDAPUrl("ldap:///???(cn=*\\2a*)") - self.assertEquals(u.filterstr, "(cn=*\\2a*)") + self.assertEqual(u.filterstr, "(cn=*\\2a*)") u = LDAPUrl("ldap:///???(cn=*%5c2a*)") - self.assertEquals(u.filterstr, "(cn=*\\2a*)") + self.assertEqual(u.filterstr, "(cn=*\\2a*)") def test_parse_extensions(self): u = LDAPUrl("ldap:///????") self.assertNone(u.extensions) self.assertNone(u.who) u = LDAPUrl("ldap:///????bindname=cn=root") - self.assertEquals(len(u.extensions), 1) - self.assertEquals(u.who, "cn=root") + self.assertEqual(len(u.extensions), 1) + self.assertEqual(u.who, "cn=root") u = LDAPUrl("ldap:///????!bindname=cn=root") - self.assertEquals(len(u.extensions), 1) - self.assertEquals(u.who, "cn=root") + self.assertEqual(len(u.extensions), 1) + self.assertEquaRefactoringTool: Refactored ./Tests/t_cext.py l(u.who, "cn=root") u = LDAPUrl("ldap:///????bindname=%3f,X-BINDPW=%2c") - self.assertEquals(len(u.extensions), 2) - self.assertEquals(u.who, "?") - self.assertEquals(u.cred, ",") + self.assertEqual(len(u.extensions), 2) + self.assertEqual(u.who, "?") + self.assertEqual(u.cred, ",") def test_parse_extensions_nulls(self): u = LDAPUrl("ldap:///????bindname=%00name") - self.assertEquals(u.who, "\0name") + self.assertEqual(u.who, "\0name") def test_parse_extensions_5questions(self): u = LDAPUrl("ldap:///????bindname=?") - self.assertEquals(len(u.extensions), 1) - self.assertEquals(u.who, "?") + self.assertEqual(len(u.extensions), 1) + self.assertEqual(u.who, "?") def test_parse_extensions_novalue(self): u = LDAPUrl("ldap:///????bindname") - self.assertEquals(len(u.extensions), 1) + self.assertEqual(len(u.extensions), 1) self.assertNone(u.who) def test_bad_urls(self): --- ./Tests/t_cext.py (original) +++ ./Tests/t_cext.py (refactored) @@ -44,29 +44,29 @@ return l def assertNotNone(self, expr, msg=None): - self.failIf(expr is None, msg or repr(expr)) + self.assertFalse(expr is None, msg or repr(expr)) def assertNone(self, expr, msg=None): - self.failIf(expr is not None, msg or repr(expr)) + self.assertFalse(expr is not None, msg or repr(expr)) # Test for the existence of a whole bunch of constants # that the C module is supposed to export def test_constants(self): - self.assertEquals(_ldap.PORT, 389) - self.assertEquals(_ldap.VERSION1, 1) - self.assertEquals(_ldap.VERSION2, 2) - self.assertEquals(_ldap.VERSION3, 3) + self.assertEqual(_ldap.PORT, 389) + self.assertEqual(_ldap.VERSION1, 1) + self.assertEqual(_ldap.VERSION2, 2) + self.assertEqual(_ldap.VERSION3, 3) # constants for result3() - self.assertEquals(_ldap.RES_BIND, 0x61) - self.assertEquals(_ldap.RES_SEARCH_ENTRY, 0x64) - self.assertEquals(_ldap.RES_SEARCH_RESULT, 0x65) - self.assertEquals(_ldap.RES_MODIFY, 0x67) - self.assertEquals(_ldap.RES_ADD, 0x69) - self.assertEquals(_ldap.RES_DELETE, 0x6b) - self.assertEquals(_ldap.RES_MODRDN, 0x6d) - self.assertEquals(_ldap.RES_COMPARE, 0x6f) - self.assertEquals(_ldap.RES_SEARCH_REFERENCE, 0x73) # v3 - self.assertEquals(_ldap.RES_EXTENDED, 0x78) # v3 + self.assertEqual(_ldap.RES_BIND, 0x61) + self.assertEqual(_ldap.RES_SEARCH_ENTRY, 0x64) + self.assertEqual(_ldap.RES_SEARCH_RESULT, 0x65) + self.assertEqual(_ldap.RES_MODIFY, 0x67) + self.assertEqual(_ldap.RES_ADD, 0x69) + self.assertEqual(_ldap.RES_DELETE, 0x6b) + self.assertEqual(_ldap.RES_MODRDN, 0x6d) + self.assertEqual(_ldap.RES_COMPARE, 0x6f) + self.assertEqual(_ldap.RES_SEARCH_REFERENCE, 0x73) # v3 + self.assertEqual(_ldap.RES_EXTENDED, 0x78) # v3 #self.assertEquals(_ldap.RES_INTERMEDIATE, 0x79) # v3 self.assertNotNone(_ldap.RES_ANY) self.assertNotNone(_ldap.RES_UNSOLICITED) @@ -144,8 +144,8 @@ self.assertNotNone(_ldap.AVA_NONPRINTABLE) # these two constants are pointless? XXX - self.assertEquals(_ldap.LDAP_OPT_ON, 1) - self.assertEquals(_ldap.LDAP_OPT_OFF, 0) + self.assertEqual(_ldap.LDAP_OPT_ON, 1) + self.assertEqual(_ldap.LDAP_OPT_OFF, 0) # these constants useless after ldap_url_parse() was dropped XXX self.assertNotNone(_ldap.URL_ERR_BADSCOPE) @@ -159,17 +159,17 @@ m = l.simple_bind("", "") result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) self.assertTrue(result, _ldap.RES_BIND) - self.assertEquals(msgid, m) - self.assertEquals(pmsg, []) - self.assertEquals(ctrls, []) + self.assertEqual(msgid, m) + self.assertEqual(pmsg, []) + self.assertEqual(ctrls, []) # see if we can get the rootdse while we're here m = l.search_ext("", _ldap.SCOPE_BASE, '(objectClass=*)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(pmsg[0][0], "") # rootDSE has no dn - self.assertEquals(msgid, m) - self.assertTrue(pmsg[0][1].has_key('objectClass')) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(pmsg[0][0], "") # rootDSE has no dn + self.assertEqual(msgid, m) + self.assertTrue('objectClass' in pmsg[0][1]) def test_unbind(self): l = self._init() @@ -188,21 +188,21 @@ result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ONE, self.timeout) # Expect to get just one object - self.assertEquals(result, _ldap.RES_SEARCH_ENTRY) - self.assertEquals(len(pmsg), 1) - self.assertEquals(len(pmsg[0]), 2) - self.assertEquals(pmsg[0][0], self.base) - self.assertEquals(pmsg[0][0], self.base) + self.assertEqual(result, _ldap.RES_SEARCH_ENTRY) + self.assertEqual(len(pmsg), 1) + self.assertEqual(len(pmsg[0]), 2) + self.assertEqual(pmsg[0][0], self.base) + self.assertEqual(pmsg[0][0], self.base) self.assertTrue('dcObject' in pmsg[0][1]['objectClass']) self.assertTrue('organization' in pmsg[0][1]['objectClass']) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ONE, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(pmsg, []) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(pmsg, []) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) def test_abandon(self): l = self._init() @@ -215,7 +215,7 @@ got_timeout = False try: r = l.result3(m, _ldap.MSG_ALL, 0.3) # (timeout /could/ be longer) - except _ldap.TIMEOUT, e: + except _ldap.TIMEOUT as e: got_timeout = True self.assertTrue(got_timeout) @@ -226,10 +226,10 @@ result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) # Expect to get some objects - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) self.assertTrue(len(pmsg) >= 2) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) def test_add(self): l = self._init() @@ -241,22 +241,22 @@ ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) - self.assertEquals(pmsg, []) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_ADD) + self.assertEqual(pmsg, []) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) # search for it back m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=Foo)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) # Expect to get the objects - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(len(pmsg), 1) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) - - self.assertEquals(pmsg[0], ('cn=Foo,'+self.base, + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(len(pmsg), 1) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) + + self.assertEqual(pmsg[0], ('cn=Foo,'+self.base, { 'objectClass': ['organizationalRole'], 'cn': ['Foo'], 'description': ['testing'] })) @@ -273,7 +273,7 @@ ('userPassword', 'the_password'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) # try a false compare m = l.compare_ext(dn, "userPassword", "bad_string") @@ -326,14 +326,14 @@ ('cn', 'Deleteme'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) m = l.delete_ext(dn) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_DELETE) - self.assertEquals(msgid, m) - self.assertEquals(pmsg, []) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_DELETE) + self.assertEqual(msgid, m) + self.assertEqual(pmsg, []) + self.assertEqual(ctrls, []) def test_modify_no_such_object(self): l = self._init() @@ -374,31 +374,31 @@ ('description', 'a description'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) m = l.modify_ext(dn, [ (_ldap.MOD_ADD, 'description', ['b desc', 'c desc']), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_MODIFY) - self.assertEquals(pmsg, []) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_MODIFY) + self.assertEqual(pmsg, []) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) # search for it back m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=AddToMe)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) # Expect to get the objects - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(len(pmsg), 1) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) - - self.assertEquals(pmsg[0][0], dn) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(len(pmsg), 1) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) + + self.assertEqual(pmsg[0][0], dn) d = list(pmsg[0][1]['description']) d.sort() - self.assertEquals(d, ['a description', 'b desc', 'c desc']) + self.assertEqual(d, ['a description', 'b desc', 'c desc']) def test_rename(self): l = self._init() @@ -408,34 +408,34 @@ ('cn', 'RenameMe'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) # do the rename with same parent m = l.rename(dn, "cn=IAmRenamed") result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_MODRDN) - self.assertEquals(msgid, m) - self.assertEquals(pmsg, []) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_MODRDN) + self.assertEqual(msgid, m) + self.assertEqual(pmsg, []) + self.assertEqual(ctrls, []) # make sure the old one is gone m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=RenameMe)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(len(pmsg), 0) # expect no results - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(len(pmsg), 0) # expect no results + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) # check that the new one looks right dn2 = "cn=IAmRenamed,"+self.base m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=IAmRenamed)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) - self.assertEquals(len(pmsg), 1) - self.assertEquals(pmsg[0][0], dn2) - self.assertEquals(pmsg[0][1]['cn'], ['IAmRenamed']) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) + self.assertEqual(len(pmsg), 1) + self.assertEqual(pmsg[0][0], dn2) + self.assertEqual(pmsg[0][1]['cn'], ['IAmRenamed']) # create the container containerDn = "ou=RenameContainer,"+self.base @@ -444,7 +444,7 @@ ('ou', 'RenameContainer'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) # WORKAROUND bug in slapd. (Without an existing child, # renames into a container object do not work for the ldif backend, @@ -455,7 +455,7 @@ ('cn', 'Bogus'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) # now rename from dn2 to the conater dn3 = "cn=IAmRenamedAgain," + containerDn @@ -463,18 +463,18 @@ # Now try renaming dn2 across container (simultaneous name change) m = l.rename(dn2, "cn=IAmRenamedAgain", containerDn) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_MODRDN) - self.assertEquals(msgid, m) - self.assertEquals(pmsg, []) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_MODRDN) + self.assertEqual(msgid, m) + self.assertEqual(pmsg, []) + self.assertEqual(ctrls, []) # make sure dn2 is gone m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=IAmRenamed)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(len(pmsg), 0) # expect no results - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(len(pmsg), 0) # expect no results + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(objectClass=*)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) @@ -482,24 +482,24 @@ # make sure dn3 is there m = l.search_ext(self.base, _ldap.SCOPE_SUBTREE, '(cn=IAmRenamedAgain)') result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_SEARCH_RESULT) - self.assertEquals(msgid, m) - self.assertEquals(ctrls, []) - self.assertEquals(len(pmsg), 1) - self.assertEquals(pmsg[0][0], dn3) - self.assertEquals(pmsg[0][1]['cn'], ['IAmRenamedAgain']) + self.assertEqual(result, _ldap.RES_SEARCH_RESULT) + self.assertEqual(msgid, m) + self.assertEqual(ctrls, []) + self.assertEqual(len(pmsg), 1) + self.assertEqual(pmsg[0][0], dn3) + self.assertEqual(pmsg[0][1]['cn'], ['IAmRenamedAgain']) def test_whoami(self): l = self._init() r = l.whoami_s() - self.assertEquals("dn:" + self.server.get_root_dn(), r) + self.assertEqual("dn:" + self.server.get_root_dn(), r) def test_whoami_unbound(self): l = self._init(bind=False) RefactoringTool: Refactored ./Tests/slapd.py RefactoringTool: Refactored ./Tests/search.py RefactoringTool: Refactored ./Tests/Lib/test_ldapurl.py l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) r = l.whoami_s() - self.assertEquals("", r) + self.assertEqual("", r) def test_whoami_anonymous(self): l = self._init(bind=False) @@ -511,7 +511,7 @@ self.assertTrue(result, _ldap.RES_BIND) r = l.whoami_s() - self.assertEquals("", r) + self.assertEqual("", r) def test_passwd(self): l = self._init() @@ -525,7 +525,7 @@ ('userPassword', 'initial'), ]) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(result, _ldap.RES_ADD) + self.assertEqual(result, _ldap.RES_ADD) # try changing password with a wrong old-pw m = l.passwd(dn, "bogus", "ignored") @@ -538,10 +538,10 @@ # try changing password with a correct old-pw m = l.passwd(dn, "initial", "changed") result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ALL, self.timeout) - self.assertEquals(msgid, m) - self.assertEquals(pmsg, []) - self.assertEquals(result, _ldap.RES_EXTENDED) - self.assertEquals(ctrls, []) + self.assertEqual(msgid, m) + self.assertEqual(pmsg, []) + self.assertEqual(result, _ldap.RES_EXTENDED) + self.assertEqual(ctrls, []) def test_options(self): oldval = _ldap.get_option(_ldap.OPT_PROTOCOL_VERSION) @@ -554,10 +554,10 @@ _ldap.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION2) v = _ldap.get_option(_ldap.OPT_PROTOCOL_VERSION) - self.assertEquals(v, _ldap.VERSION2) + self.assertEqual(v, _ldap.VERSION2) _ldap.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) v = _ldap.get_option(_ldap.OPT_PROTOCOL_VERSION) - self.assertEquals(v, _ldap.VERSION3) + self.assertEqual(v, _ldap.VERSION3) finally: _ldap.set_option(_ldap.OPT_PROTOCOL_VERSION, oldval) @@ -567,11 +567,11 @@ l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION2) v = l.get_option(_ldap.OPT_PROTOCOL_VERSION) - self.assertEquals(v, _ldap.VERSION2) + self.assertEqual(v, _ldap.VERSION2) l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) v = l.get_option(_ldap.OPT_PROTOCOL_VERSION) - self.assertEquals(v, _ldap.VERSION3) + self.assertEqual(v, _ldap.VERSION3) # Try setting options that will yield a known error. try: --- ./Tests/slapd.py (original) +++ ./Tests/slapd.py (refactored) @@ -374,10 +374,10 @@ 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((name + ": " + val)) print("") - print(slapd.get_url()) + print((slapd.get_url())) slapd.wait() --- ./Tests/search.py (original) +++ ./Tests/search.py (refactored) @@ -15,7 +15,7 @@ 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 @@ -37,6 +37,6 @@ 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() --- ./Tests/Lib/test_ldapurl.py (original) +++ ./Tests/Lib/test_ldapurl.py (refactored) @@ -5,7 +5,7 @@ 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, @@ -25,14 +25,14 @@ 'ldp://root.openldap.org/dc=openldap,dc=org':0, 'ldap://localhost:1389/ou%3DUnstructured%20testing%20tree%2Cdc%3Dstroeder%2Cdc%3Dcom??one':1, } -for ldap_url in is_ldap_url_tests.keys(): +for ldap_url in list(is_ldap_url_tests.keys()): reRefactoringTool: Refactored ./Tests/Lib/ldap/test_modlist.py RefactoringTool: Refactored ./Tests/Lib/ldap/schema/test_tokenizer.py RefactoringTool: Refactored ./Lib/ldif.py sult_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 @@ 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') --- ./Tests/Lib/ldap/test_modlist.py (original) +++ ./Tests/Lib/ldap/test_modlist.py (refactored) @@ -6,7 +6,7 @@ from ldap.modlist import addModlist,modifyModlist -print '\nTesting function addModlist():' +print('\nTesting function addModlist():') addModlist_tests = [ ( { @@ -31,11 +31,11 @@ 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 = [ ( { @@ -103,9 +103,9 @@ 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) - ) + )) --- ./Tests/Lib/ldap/schema/test_tokenizer.py (original) +++ ./Tests/Lib/ldap/schema/test_tokenizer.py (refactored) @@ -25,6 +25,6 @@ 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) --- ./Lib/ldif.py (original) +++ ./Lib/ldif.py (refactored) @@ -23,12 +23,12 @@ 'LDIFCopy', ] -import urlparse,urllib,base64,re,types +import urllib.parse,urllib.request,urllib.parse,urllib.error,base64,re,types try: - from cStringIO import StringIO + from io import StringIO except ImportError: - from StringIO import StringIO + from io import StringIO attrtype_pattern = r'[\w;.-]+(;[\w_-]+)*' attrvalue_pattern = r'(([^,]|\\,)+|".*?")' @@ -124,7 +124,7 @@ returns 1 if attr_value has to be base-64 encoded because of special chars or because attr_type is in self._base64_attrs """ - return self._base64_attrs.has_key(attr_type.lower()) or \ + return attr_type.lower() in self._base64_attrs or \ not safe_string_re.search(attr_value) is None def _unparseAttrTypeandValue(self,attr_type,attr_value): @@ -148,7 +148,7 @@ entry RefactoringTool: Refactored ./Lib/ldapurl.py dictionary holding an entry """ - attr_types = entry.keys()[:] + attr_types = list(entry.keys())[:] attr_types.sort() for attr_type in attr_types: for attr_value in entry[attr_type]: @@ -165,7 +165,7 @@ elif mod_len==3: changetype = 'modify' else: - raise ValueError,"modlist item of wrong length" + raise ValueError("modlist item of wrong length") self._unparseAttrTypeandValue('changetype',changetype) for mod in modlist: if mod_len==2: @@ -174,7 +174,7 @@ mod_op,mod_type,mod_vals = mod self._unparseAttrTypeandValue(MOD_OP_STR[mod_op],mod_type) else: - raise ValueError,"Subsequent modlist item of wrong length" + raise ValueError("Subsequent modlist item of wrong length") if mod_vals: for mod_val in mod_vals: self._unparseAttrTypeandValue(mod_type,mod_val) @@ -195,12 +195,12 @@ # Start with line containing the distinguished name self._unparseAttrTypeandValue('dn',dn) # Dispatch to record type specific writers - if isinstance(record,types.DictType): + if isinstance(record,dict): self._unparseEntryRecord(record) - elif isinstance(record,types.ListType): + elif isinstance(record,list): self._unparseChangeRecord(record) else: - raise ValueError, "Argument record must be dictionary or list" + raise ValueError("Argument record must be dictionary or list") # Write empty line separating the records self._output_file.write(self._line_sep) # Count records written @@ -329,9 +329,9 @@ url = unfolded_line[colon_pos+2:].strip() attr_value = None if self._process_url_schemes: - u = urlparse.urlparse(url) - if self._process_url_schemes.has_key(u[0]): - attr_value = urllib.urlopen(url).read() + u = urllib.parse.urlparse(url) + if u[0] in self._process_url_schemes: + attr_value = urllib.request.urlopen(url).read() elif value_spec==':\r\n' or value_spec=='\n': attr_value = '' else: @@ -356,25 +356,25 @@ if attr_type=='dn': # attr type and value pair was DN of LDIF record if dn!=None: - raise ValueError, 'Two lines starting with dn: in one record.' + raise ValueError('Two lines starting with dn: in one record.') if not is_dn(attr_value): - raise ValueError, 'No valid string-representation of distinguished name %s.' % (repr(attr_value)) + raise ValueError('No valid string-representation of distinguished name %s.' % (repr(attr_value))) dn = attr_value elif attr_type=='version' and dn is None: version = 1 elif attr_type=='changetype': # attr type and value pair was DN of LDIF record if dn is None: - raise ValueError, 'Read changetype: before getting valid dn: line.' + raise ValueError('Read changetype: before getting valid dn: line.') if changetype!=None: - raise ValueError, 'Two lines starting with changetype: in one record.' - if not valid_changetype_dict.has_key(attr_value): - raise ValueError, 'changetype value %s is invalid.' % (repr(attr_value)) + raise ValueError('Two lines starting with changetype: in one record.') + if attr_value not in valid_changetype_dict: + raise ValueError('changetype value %s is invalid.' % (repr(attr_value))) changetype = attr_value elif attr_value!=None and \ - not self._ignored_attr_types.has_key(attr_type.lower()): + attr_type.lower() not in self._ignored_attr_types: # Add the attribute to the entry if not ignored attribute - if entry.has_key(attr_type): + if attr_type in entry: entry[attr_type].append(attr_value) else: entry[attr_type]=[attr_value] --- ./Lib/ldapurl.py (original) +++ ./Lib/ldapurl.py (refactored) @@ -28,7 +28,7 @@ except ImportError: from collectionsRefactoringTool: Refactored ./Lib/ldap/schema/tokenizer.py import UserDict -from urllib import quote,unquote +from urllib.parse import quote, unquote LDAP_SCOPE_BASE = 0 LDAP_SCOPE_ONELEVEL = 1 @@ -142,7 +142,7 @@ def __init__(self,default=None): UserDict.__init__(self) - for k,v in (default or {}).items(): + for k,v in list((default or {}).items()): self[k]=v def __setitem__(self,name,value): @@ -158,11 +158,11 @@ def values(self): return [ self[k] - for k in self.keys() + for k in list(self.keys()) ] def __str__(self): - return ','.join(map(str,self.values())) + return ','.join(map(str,list(self.values()))) def __repr__(self): return '<%s.%s instance at %s: %s>' % ( @@ -185,7 +185,7 @@ self[e.extype] = e def unparse(self): - return ','.join([ v.unparse() for v in self.values() ]) + return ','.join([ v.unparse() for v in list(self.values()) ]) class LDAPUrl: @@ -258,11 +258,11 @@ urlscheme,host,dn,attrs,scope,filterstr,extensions """ if not isLDAPUrl(ldap_url): - raise ValueError,'Parameter ldap_url does not seem to be a LDAP URL.' + raise ValueError('Parameter ldap_url does not seem to be a LDAP URL.') scheme,rest = ldap_url.split('://',1) self.urlscheme = scheme.strip() if not self.urlscheme in ['ldap','ldaps','ldapi']: - raise ValueError,'LDAP URL contains unsupported URL scheme %s.' % (self.urlscheme) + raise ValueError('LDAP URL contains unsupported URL scheme %s.' % (self.urlscheme)) slash_pos = rest.find('/') qemark_pos = rest.find('?') if (slash_pos==-1) and (qemark_pos==-1): @@ -282,7 +282,7 @@ # Do not eat question mark rest = rest[qemark_pos:] else: - raise ValueError,'Something completely weird happened!' + raise ValueError('Something completely weird happened!') paramlist=rest.split('?',4) paramlist_len = len(paramlist) if paramlist_len>=1: @@ -294,7 +294,7 @@ try: self.scope = SEARCH_SCOPE[scope] except KeyError: - raise ValueError,"Search scope must be either one of base, one or sub. LDAP URL contained %s" % (repr(scope)) + raise ValueError("Search scope must be either one of base, one or sub. LDAP URL contained %s" % (repr(scope))) if paramlist_len>=4: filterstr = paramlist[3].strip() if not filterstr: @@ -317,7 +317,7 @@ Dictionary containing a mapping from class attributes to default values """ - for k in defaults.keys(): + for k in list(defaults.keys()): if getattr(self,k) is None: setattr(self,k,defaults[k]) @@ -386,22 +386,22 @@ ) def __getattr__(self,name): - if self.attr2extype.has_key(name): + if name in self.attr2extype: extype = self.attr2extype[name] if self.extensions and \ - self.extensions.has_key(extype) and \ + extype in self.extensions and \ not self.extensions[extype].exvalue is None: result = unquote(self.extensions[extype].exvalue) else: return None else: - raise AttributeError,"%s has no attribute %s" % ( + raise AttributeError("%s has no attribute %s" % ( self.__class__.__name__,name - ) + )) return result # __getattr__() def __setattr__(self,name,value): - if self.attr2extype.has_key(name): + if name in self.attr2extype: extype = self.attr2extype[name] if value is None: # A value of None means that extension is deleted @@ -415,7 +415,7 @@ self.__dict__[name] = value def __delattr__(self,name): - if self.attr2extype.has_key(name): + if name in self.attr2extype: extype = self.attr2extype[name] if self.extensions: try: --- ./Lib/ldap/schema/tokenizer.py (original) +++ ./Lib/ldap/schema/tokenizer.py (refactored) @@ -73,7 +73,7 @@ start = i while i=2: self._trace_file.write('=> LDAPError - %s: %s\n' % (e.__class__.__name__,str(e))) raise @@ -114,20 +114,20 @@ return result def __setattr__(self,name,value): - if self.CLASSATTR_OPTION_MAPPING.has_key(name): + if name in self.CLASSATTR_OPTION_MAPPING: self.set_option(self.CLASSATTR_OPTION_MAPPING[name],value) else: self.__dict__[name] = value def __getattr__(self,name): - if self.CLASSATTR_OPTION_MAPPING.has_key(name): + if name in self.CLASSATTR_OPTION_MAPPING: return self.get_option(self.CLASSATTR_OPTION_MAPPING[name]) - elif self.__dict__.has_key(name): + elif name in self.__dict__: return self.__dict__[name] else: - raise AttributeError,'%s has no attribute %s' % ( + raise AttributeError('%s has no attribute %s' % ( self.__class__.__name__,repr(name) - ) + )) def abandon_ext(self,msgid,serverctrls=None,clientctrls=None): """ @@ -693,13 +693,13 @@ self._retry_max = retry_max self._retry_delay = retry_delay self._start_tls = 0 - self._reconnects_done = 0L + self._reconnects_done = 0 def __getstate__(self): """return data representation for pickled object""" d = {} - for k,v in self.__dict__.items(): - if not self.__transient_attrs__.has_key(k): + for k,v in list(self.__dict__.items()): + if k not in self.__transient_attrs__: d[k] = v return d @@ -717,7 +717,7 @@ def _restore_options(self): """Restore all recorded options""" - for k,v in self._options.items(): + for k,v in list(self._opRefactoringTool: Refactored ./Lib/ldap/functions.py RefactoringTool: No changes to ./Lib/ldap/filter.py RefactoringTool: No changes to ./Lib/ldap/dn.py RefactoringTool: No changes to ./Lib/ldap/controls.py RefactoringTool: Refactored ./Lib/ldap/cidict.py RefactoringTool: Refactored ./Lib/ldap/async.py tions.items()): SimpleLDAPObject.set_option(self,k,v) def reconnect(self,uri): @@ -738,7 +738,7 @@ self.start_tls_s() # Repeat last simple or SASL bind self._apply_last_bind() - except ldap.SERVER_DOWN,e: + except ldap.SERVER_DOWN as e: SimpleLDAPObject.unbind_s(self) del self._l if __debug__ and self._trace_level>=1: @@ -756,11 +756,11 @@ self._trace_file.write('*** %d. reconnect to %s successful, last operation will be repeated\n' % ( self._retry_max-reconnect_counter+1,uri )) - self._reconnects_done = self._reconnects_done + 1L + self._reconnects_done = self._reconnects_done + 1 break def _apply_method_s(self,func,*args,**kwargs): - if not self.__dict__.has_key('_l'): + if '_l' not in self.__dict__: self.reconnect(self._uri) try: return func(self,*args,**kwargs) --- ./Lib/ldap/functions.py (original) +++ ./Lib/ldap/functions.py (refactored) @@ -64,7 +64,7 @@ finally: if lock: ldap._ldap_module_lock.release() - except LDAPError,e: + except LDAPError as e: if __debug__ and ldap._trace_level>=2: ldap._trace_file.write('=> LDAPError: %s\n' % (str(e))) raise --- ./Lib/ldap/cidict.py (original) +++ ./Lib/ldap/cidict.py (refactored) @@ -40,14 +40,14 @@ del self.data[lower_key] def update(self,dict): - for key in dict.keys(): + for key in list(dict.keys()): self[key] = dict[key] def has_key(self,key): return UserDict.has_key(self,lower(key)) def __contains__(self,key): - return self.has_key(key) + return key in self def get(self,key,failobj=None): try: @@ -56,11 +56,11 @@ return failobj def keys(self): - return self._keys.values() + return list(self._keys.values()) def items(self): result = [] - for k in self._keys.values(): + for k in list(self._keys.values()): result.append((k,self[k])) return result @@ -76,7 +76,7 @@ result = [ elt for elt in a - if not temp.has_key(elt) + if elt not in temp ] return result @@ -91,7 +91,7 @@ result = [ temp[elt] for elt in b - if temp.has_key(elt) + if elt in temp ] return result @@ -105,7 +105,7 @@ temp[elt] = elt for elt in b: temp[elt] = elt - return temp.values() + return list(temp.values()) if __debug__ and __name__ == '__main__': @@ -117,12 +117,12 @@ cix["xYZ"] = 987 assert cix["XyZ"] == 987 assert cix.get("XyZ",None) == 987 - cix_keys = cix.keys() + cix_keys = list(cix.keys()) cix_keys.sort() assert cix_keys==['AbCDeF','xYZ'],ValueError(repr(cix_keys)) - cix_items = cix.items() + cix_items = list(cix.items()) cix_items.sort() assert cix_items==[('AbCDeF',123),('xYZ',987)],ValueError(repr(cix_items)) del cix["abcdEF"] - assert not cix._keys.has_key("abcdef") - assert not cix.has_key("AbCDef") + assert "abcdef" not in cix._keys + assert "AbCDef" not in cix --- ./Lib/ldap/async.py (original) +++ ./Lib/ldap/async.py (refactored) @@ -130,8 +130,8 @@ result_type,result_list,result_msgid,result_serverctrls = self._l.result3(self._msgId,0,timeout) if not result_list: break - if not _searchResultTypes.has_key(result_type): - raise WrongResultType(result_type,_searchResultTypes.keys()) + if result_type not in _searchResultTypes: + raise WrongResultType(result_type,list(_searchResultTypes.keys())) # Loop over list of search results for result_item in result_list: if result_counter%s\n' % (self._indent*4,oc)) self._output_file.write('%s\n' % (self._indent*3)) - attr_types = entry.keys()[:] + attr_types = list(entry.keys())[:] try: attr_types.remove('objectclass') attr_types.remove('objectClass') @@ -199,7 +199,7 @@ self._oc_value = '' # Unhandled tags else: - raise ValueError,'Unknown tag %s' % (raw_name) + raise ValueError('Unknown tag %s' % (raw_name)) def endElement(self,raw_name): assert raw_name.startswith('dsml:'),'Illegal name' @@ -234,12 +234,12 @@ del self._oc_value # Unhandled tags else: - raise ValueError,'Unknown tag %s' % (raw_name) + raise ValueError('Unknown tag %s' % (raw_name)) def characters(self,ch): - if self.__dict__.has_key('_oc_value'): + if '_oc_value' in self.__dict__: self._oc_value = self._oc_value + ch - elif self.__dict__.has_key('_attr_value'): + elif '_attr_value' in self.__dict__: self._attr_value = self._attr_value + ch else: pass @@ -276,7 +276,7 @@ """ self._input_file = input_file self._max_entries = max_entries - self._ignored_attr_types = list_dict(map(string.lower,(ignored_attr_types or []))) + self._ignored_attr_types = list_dict(list(map(string.lower,(ignored_attr_types or [])))) self._current_record = None,None self.records_read = 0 self._parser = xml.sax.make_parser()RefactoringTool: No changes to ./Doc/conf.py RefactoringTool: Refactored ./Demo/simplebrowse.py RefactoringTool: Refactored ./Demo/simple.py RefactoringTool: Refactored ./Demo/schema_tree.py --- ./Demo/simplebrowse.py (original) +++ ./Demo/simplebrowse.py (refactored) @@ -11,7 +11,7 @@ url = "ldap://ldap.openldap.org/" dn = "dc=openldap,dc=org" -print "Connecting to", url +print("Connecting to", url) l = ldap.initialize(url) l.bind_s("", "", ldap.AUTH_SIMPLE); @@ -23,26 +23,26 @@ #-- read a command try: - cmd = raw_input(dn + "> ") + cmd = input(dn + "> ") except EOFError: - print + print() break try: if cmd == "?": - print "cd - change DN to " - print "cd - change DN to number of last 'ls'" - print "cd - - change to previous DN" - print "cd .. - change to one-level higher DN" - print "cd - change to root DN" - print "ls - list children of crrent DN" - print ". - show attributes of current DN" - print "/ - list descendents matching filter " - print "? - show this help" + print("cd - change DN to ") + print("cd - change DN to number of last 'ls'") + print("cd - - change to previous DN") + print("cd .. - change to one-level higher DN") + print("cd - change to root DN") + print("ls - list children of crrent DN") + print(". - show attributes of current DN") + print("/ - list descendents matching filter ") + print("? - show this help") elif cmd == "ls": - print "Children of", `dn`, ":" + print("Children of", repr(dn), ":") dnlist = [] # # List the children at one level down from the current dn @@ -59,7 +59,7 @@ shortname = name[:-len(dn)-2]+" +" else: shortname = name - print " %3d. %s" % (len(dnlist), shortname) + print(" %3d. %s" % (len(dnlist), shortname)) dnlist.append(name) elif cmd == "cd": @@ -80,7 +80,7 @@ godn = arg else: if dnlist is None: - print "do an ls first" + print("do an ls first") else: godn = dnlist[i] lastdn = dn @@ -94,18 +94,18 @@ # No attributes are listed, so the default is for # the client to receive all attributes on the DN. # - print "Attributes of", `dn`, ":" + print("Attributes of", repr(dn), ":") for name,attrs in l.search_s(dn, ldap.SCOPE_BASE, "objectclass=*"): - print " %-24s" % name - for k,vals in attrs.items(): + print(" %-24s" % name) + for k,vals in list(attrs.items()): for v in vals: if len(v) > 200: - v = `v[:200]` + \ + v = repr(v[:200]) + \ ("... (%d bytes)" % len(v)) else: - v = `v` - print " %-12s: %s" % (k, v) + v = repr(v) + print(" %-12s: %s" % (k, v)) elif cmd.startswith("/"): # @@ -115,13 +115,13 @@ # that we're not interested in them. # expr = cmd[1:] - print "Descendents matching filter", `expr`, ":" + print("Descendents matching filter", repr(expr), ":") for name,attrs in l.search_s(dn, ldap.SCOPE_SUBTREE, expr, []): - print " %24s", name + print(" %24s", name) else: - print "unknown command - try '?' for help" + print("unknown command - try '?' for help") except: print_exc() --- ./Demo/simple.py (original) +++ ./Demo/simple.py (refactored) @@ -14,7 +14,7 @@ try: dn = "ou=CSEE,o=UQ,c=AU" - print "Adding", repr(dn) + print("Adding", repr(dn)) l.add_s(dn, [ ("objectclass",["organizationalUnit"]), @@ -32,7 +32,7 @@ # dn = "cn=David Leonard,ou=CSEE,o=UQ,c=AU" -print "Updating", repr(dn) +print("Updating", repr(dn)) try: l.delete_s(dn) @@ -100,7 +100,7 @@ _ldap.SCOPE_SUBTREE, "objectclass=*", ) -print res +print(res) l.unbind() --- ./Demo/schema_tree.py (original) +++ ./Demo/schema_tree.py (refactored) @@ -14,11 +14,11 @@ """ASCII text output for console""" se_obj = schema.get_obj(se_class,se_oid) if se_obj!=None: - print '| '*(level-1)+'+---'*(level>0), \ + print('| '*(level-1)+'+---'*(level>0), \ ', '.join(se_obj.names), \ - '(%s)' % se_obj.oid + '(%s)' % se_obj.oid) for sub_se_oid in se_tree[se_oid]: - RefactoringTool: Refactored ./Demo/schema.py print '| '*(level+1) + print('| '*(level+1)) PrintSchemaTree(schema,se_class,se_tree,sub_se_oid,level+1) @@ -26,17 +26,17 @@ """HTML output for browser""" se_obj = schema.get_obj(se_class,se_oid) if se_obj!=None: - print """ + print("""
%s (%s)
%s - """ % (', '.join(se_obj.names),se_obj.oid,se_obj.desc) + """ % (', '.join(se_obj.names),se_obj.oid,se_obj.desc)) if se_tree[se_oid]: - print '
' + print('
') for sub_se_oid in se_tree[se_oid]: HTMLSchemaTree(schema,se_class,se_tree,sub_se_oid,level+1) - print '
' - print '
' + print('') + print('') ldap.set_option(ldap.OPT_DEBUG_LEVEL,0) @@ -46,13 +46,13 @@ subschemasubentry_dn,schema = ldap.schema.urlfetch(sys.argv[-1],ldap.trace_level) if subschemasubentry_dn is None: - print 'No sub schema sub entry found!' + print('No sub schema sub entry found!') sys.exit(1) try: options,args=getopt.getopt(sys.argv[1:],'',['html']) -except getopt.error,e: - print 'Error: %s\nUsage: schema_oc_tree.py [--html] [LDAP URL]' +except getopt.error as e: + print('Error: %s\nUsage: schema_oc_tree.py [--html] [LDAP URL]') html_output = options and options[0][0]=='--html' @@ -66,35 +66,35 @@ if html_output: - print """ + print(""" Object class tree

Object class tree

-""" +""") HTMLSchemaTree(schema,ldap.schema.ObjectClass,oc_tree,'2.5.6.0',0) - print """
+ print("""

Attribute type tree

-""" +""") for a in schema.listall(ldap.schema.AttributeType): if at_tree[a]: HTMLSchemaTree(schema,ldap.schema.AttributeType,at_tree,a,0) - print + print() - print """
+ print(""" -""" +""") else: - print '*** Object class tree ***\n' - print + print('*** Object class tree ***\n') + print() PrintSchemaTree(schema,ldap.schema.ObjectClass,oc_tree,'2.5.6.0',0) - print '\n*** Attribute types tree ***\n' + print('\n*** Attribute types tree ***\n') PrintSchemaTree(schema,ldap.schema.AttributeType,at_tree,'_',0) --- ./Demo/schema.py (original) +++ ./Demo/schema.py (refactored) @@ -11,51 +11,51 @@ schema_reverse = ldap.schema.SubSchema(schema.ldap_entry()) if subschemasubentry_dn is None: - print 'No sub schema sub entry found!' + print('No sub schema sub entry found!') sys.exit(1) -print '*** Schema from',repr(subschemasubentry_dn) +print('*** Schema from',repr(subschemasubentry_dn)) # Display schema -for attr_type,schema_class in ldap.schema.SCHEMA_CLASS_MAPPING.items(): - print '*'*20,attr_type,'*'*20 +for attr_type,schema_class in list(ldap.schema.SCHEMA_CLASS_MAPPING.items()): + print('*'*20,attr_type,'*'*20) for element_id in schema.listall(schema_class): se_orig = schema.get_obj(schema_class,element_id) se_reverse = schema_reverse.get_obj(schema_class,element_id) # assert str(se_orig)==str(se_reverse) - print attr_type,str(se_orig) -print '*** Testing object class inetOrgPerson ***' + print(attr_type,str(se_orig)) +print('*** Testing object class inetOrgPerson ***') inetOrgPerson = schema.get_obj(ldap.schema.ObjectClass,'inetOrgPerson') if not inetOrgPerson is None: - print inetOrgPerson.must,inetOrgPerson.may + print(inetOrgPerson.must,inetOrgPerson.may) -print '*** person,organizationalPerson,inetOrgPerson ***' +print('*** person,organizationalPerson,inetOrgPerson ***') try: - print schema.attribute_types( + print(schema.attribute_types( ['person','organizationalPerson','inetOrgPerson'] - ) - print schema.attribute_types( + )) + print(schema.attribute_types( ['person','organizationalPerson','inetOrgPerson'], attr_type_filter = [ ('no_user_mod',[0]), - ('usage',range(2)), + ('usage',list(range(2))), ] - ) -except KeyError,e: - print '***KeyError',str(e) + )) +except KeyError as e: + print('***KeyError',str(e)) drink = schema.get_obj(ldap.schema.AttribuRefactoringTool: Refactored ./Demo/sasl_bind.py RefactoringTool: Refactored ./Demo/resiter.py RefactoringTool: Refactored ./Demo/rename.py RefactoringTool: No changes to ./Demo/reconnect.py RefactoringTool: Refactored ./Demo/pyasn1/prereadcontrol.py RefactoringTool: No changes to ./Demo/pickle_ldapobject.py RefactoringTool: Refactored ./Demo/passwd_ext_op.py RefactoringTool: Refactored ./Demo/page_control.py teType,'favouriteDrink') if not drink is None: - print '*** drink ***' - print 'drink.names',repr(drink.names) - print 'drink.collective',repr(drink.collective) + print('*** drink ***') + print('drink.names',repr(drink.names)) + print('drink.collective',repr(drink.collective)) schema.ldap_entry() -print str(schema.get_obj(ldap.schema.MatchingRule,'2.5.13.0')) -print str(schema.get_obj(ldap.schema.MatchingRuleUse,'2.5.13.0')) +print(str(schema.get_obj(ldap.schema.MatchingRule,'2.5.13.0'))) +print(str(schema.get_obj(ldap.schema.MatchingRuleUse,'2.5.13.0'))) -print str(schema.get_obj(ldap.schema.AttributeType,'name')) -print str(schema.get_inheritedobj(ldap.schema.AttributeType,'cn',['syntax','equality','substr','ordering'])) +print(str(schema.get_obj(ldap.schema.AttributeType,'name'))) +print(str(schema.get_inheritedobj(ldap.schema.AttributeType,'cn',['syntax','equality','substr','ordering']))) --- ./Demo/sasl_bind.py (original) +++ ./Demo/sasl_bind.py (refactored) @@ -60,23 +60,23 @@ ), ]: sasl_auth = ldap.sasl.sasl(sasl_cb_value_dict,sasl_mech) - print 20*'*',sasl_auth.mech,20*'*' + print(20*'*',sasl_auth.mech,20*'*') # Open the LDAP connection l = ldap.initialize(ldap_uri,trace_level=0) # Set protocol version to LDAPv3 to enable SASL bind! l.protocol_version = 3 try: l.sasl_interactive_bind_s("", sasl_auth) - except ldap.LDAPError,e: - print 'Error using SASL mechanism',sasl_auth.mech,str(e) + except ldap.LDAPError as e: + print('Error using SASL mechanism',sasl_auth.mech,str(e)) else: - print 'Sucessfully bound using SASL mechanism:',sasl_auth.mech + print('Sucessfully bound using SASL mechanism:',sasl_auth.mech) try: - print 'Result of Who Am I? ext. op:',repr(l.whoami_s()) - except ldap.LDAPError,e: - print 'Error using SASL mechanism',sasl_auth.mech,str(e) + print('Result of Who Am I? ext. op:',repr(l.whoami_s())) + except ldap.LDAPError as e: + print('Error using SASL mechanism',sasl_auth.mech,str(e)) try: - print 'OPT_X_SASL_USERNAME',repr(l.get_option(ldap.OPT_X_SASL_USERNAME)) + print('OPT_X_SASL_USERNAME',repr(l.get_option(ldap.OPT_X_SASL_USERNAME))) except AttributeError: pass --- ./Demo/resiter.py (original) +++ ./Demo/resiter.py (refactored) @@ -21,6 +21,6 @@ result_iter = l.allresults(msgid) for result_type,result_list,result_msgid,result_serverctrls in result_iter: - print result_type,result_list,result_msgid,result_serverctrls + print(result_type,result_list,result_msgid,result_serverctrls) l.unbind_s() --- ./Demo/rename.py (original) +++ ./Demo/rename.py (refactored) @@ -4,7 +4,7 @@ # Create LDAPObject instance l = ldap.initialize('ldap://localhost:1389',trace_level=1) -print 'Password:' +print('Password:') cred = getpass() try: @@ -15,7 +15,7 @@ # Try a bind to provoke failure if protocol version is not supported l.bind_s('cn=root,dc=stroeder,dc=com',cred,ldap.AUTH_SIMPLE) - print 'Using rename_s():' + print('Using rename_s():') l.rename_s( 'uid=fred,ou=Unstructured testing tree,dc=stroeder,dc=com', --- ./Demo/pyasn1/prereadcontrol.py (original) +++ ./Demo/pyasn1/prereadcontrol.py (refactored) @@ -55,4 +55,4 @@ msg = ld.modify_ext("cn=unixIdPool,dc=example,dc=com", modlist, serverctrls = [pr]) res = ld.result3(msgid = msg, timeout = -1) -print "res:", res +print("res:", res) --- ./Demo/passwd_ext_op.py (original) +++ ./Demo/passwd_ext_op.py (refactored) @@ -11,9 +11,9 @@ lu = ldapurl.LDAPUrl(sys.argv[1]) -print 'Old password' +print('Old password') oldpw = getpass.getpass() -print 'New password' +print('New password') newpw = getpass.getpass() # Set path name of file containing all CA certificates --- ./Demo/page_control.py (original) +++ ./Demo/page_control.py (refactored) @@ -30,9 +30,9 @@ pages = 0 while True: pages += 1 - print "Getting page %d" % (pages,) + print("Getting page %d" % (pages,)) rtype, rdata, rmsgid, serverctrls = l.result3(msgid) - print '%d results' % len(rdata) + print('%d results' % len(RefactoringTool: Refactored ./Demo/options.py RefactoringTool: No changes to ./Demo/ms_ad_bind.py RefactoringTool: Refactored ./Demo/matchedvalues.py RefactoringTool: Refactored ./Demo/ldapcontrols.py RefactoringTool: Refactored ./Demo/initialize.py rdata)) # pprint.pprint(rdata) pctrls = [ c @@ -53,5 +53,5 @@ else: break else: - print "Warning: Server ignores RFC 2696 control." + print("Warning: Server ignores RFC 2696 control.") break --- ./Demo/options.py (original) +++ ./Demo/options.py (refactored) @@ -3,25 +3,25 @@ host="localhost:1390" -print "API info:",ldap.get_option(ldap.OPT_API_INFO) -print "debug level:",ldap.get_option(ldap.OPT_DEBUG_LEVEL) +print("API info:",ldap.get_option(ldap.OPT_API_INFO)) +print("debug level:",ldap.get_option(ldap.OPT_DEBUG_LEVEL)) #print "Setting debug level to 255..." #ldap.set_option(ldap.OPT_DEBUG_LEVEL,255) #print "debug level:",ldap.get_option(ldap.OPT_DEBUG_LEVEL) -print "default size limit:",ldap.get_option(ldap.OPT_SIZELIMIT) -print "Setting default size limit to 10..." +print("default size limit:",ldap.get_option(ldap.OPT_SIZELIMIT)) +print("Setting default size limit to 10...") ldap.set_option(ldap.OPT_SIZELIMIT,10) -print "default size limit:",ldap.get_option(ldap.OPT_SIZELIMIT) -print "Creating connection to",host,"..." +print("default size limit:",ldap.get_option(ldap.OPT_SIZELIMIT)) +print("Creating connection to",host,"...") l=ldap.init(host) -print "size limit:",l.get_option(ldap.OPT_SIZELIMIT) -print "Setting connection size limit to 20..." +print("size limit:",l.get_option(ldap.OPT_SIZELIMIT)) +print("Setting connection size limit to 20...") l.set_option(ldap.OPT_SIZELIMIT,20) -print "size limit:",l.get_option(ldap.OPT_SIZELIMIT) +print("size limit:",l.get_option(ldap.OPT_SIZELIMIT)) #print "Setting time limit to 60 secs..." l.set_option(ldap.OPT_TIMELIMIT,60) #print "time limit:",l.get_option(ldap.OPT_TIMELIMIT) -print "Binding..." +print("Binding...") l.simple_bind_s("","") --- ./Demo/matchedvalues.py (original) +++ ./Demo/matchedvalues.py (refactored) @@ -33,11 +33,11 @@ def print_result(search_result): for n in range(len(search_result)): - print "dn: %s" % search_result[n][0] - for attr in search_result[n][1].keys(): + print("dn: %s" % search_result[n][0]) + for attr in list(search_result[n][1].keys()): for i in range(len(search_result[n][1][attr])): - print "%s: %s" % (attr, search_result[n][1][attr][i]) - print + print("%s: %s" % (attr, search_result[n][1][attr][i])) + print() uri = "ldap://ldap.example.com" @@ -51,13 +51,13 @@ mv = MatchedValuesControl(criticality=True, controlValue=control_filter) res = ld.search_ext_s(base, scope, filter, attrlist = ['mail']) -print "LDAP filter used: %s" % filter -print "Requesting 'mail' attribute back" -print -print "No matched values control:" +print("LDAP filter used: %s" % filter) +print("Requesting 'mail' attribute back") +print() +print("No matched values control:") print_result(res) res = ld.search_ext_s(base, scope, filter, attrlist = ['mail'], serverctrls = [mv]) -print "Matched values control: %s" % control_filter +print("Matched values control: %s" % control_filter) print_result(res) --- ./Demo/ldapcontrols.py (original) +++ ./Demo/ldapcontrols.py (refactored) @@ -4,12 +4,12 @@ l = ldap.initialize('ldap://localhost:1390',trace_level=2) -print 60*'#' +print(60*'#') pprint.pprint(l.get_option(ldap.OPT_SERVER_CONTROLS)) l.manage_dsa_it(1,1) pprint.pprint(l.get_option(ldap.OPT_SERVER_CONTROLS)) -print 60*'#' +print(60*'#') # Search with ManageDsaIT control (which has no value) pprint.pprint(l.search_ext_s( @@ -19,7 +19,7 @@ ['*','+'], serverctrls = [ LDAPControl('2.16.840.1.113730.3.4.2',1,None) ], )) -print 60*'#' +print(60*'#') # Search with Subentries control (which has boolean value) pprint.pprint(l.search_ext_s( @@ -30,4 +30,4 @@ serverctrls = [ BooleanControl('1.3.6.1.4.1.4203.1.10.1',1,1) ], )) -print 60*'#' +print(60*'#') --- ./Demo/initialize.py (original) +++ ./Demo/initialize.py (refactored) @@ -26,10 +26,10 @@ ldap.set_option(ldap.OPT_X_TLS_CACERTFILE,CACERTFILE) -print """################################################RefactoringTool: No changes to ./Demo/Lib/ldif/ldifcopy.py RefactoringTool: Refactored ./Demo/Lib/ldapurl/urlsearch.py RefactoringTool: No changes to ./Demo/Lib/ldap/async/sizelimit.py RefactoringTool: No changes to ./Demo/Lib/ldap/async/ldifwriter.py RefactoringTool: Refactored ./Demo/Lib/ldap/async/deltree.py RefactoringTool: Files that were modified: RefactoringTool: ./setup.py RefactoringTool: ./Tests/t_search.py RefactoringTool: ./Tests/t_ldapurl.py RefactoringTool: ./Tests/t_cext.py RefactoringTool: ./Tests/slapd.py RefactoringTool: ./Tests/search.py RefactoringTool: ./Tests/Lib/test_ldapurl.py RefactoringTool: ./Tests/Lib/ldap/test_modlist.py RefactoringTool: ./Tests/Lib/ldap/schema/test_tokenizer.py RefactoringTool: ./Lib/ldif.py RefactoringTool: ./Lib/ldapurl.py RefactoringTool: ./Lib/ldap/schema/tokenizer.py RefactoringTool: ./Lib/ldap/schema/subentry.py RefactoringTool: ./Lib/ldap/schema/models.py RefactoringTool: ./Lib/ldap/schema/__init__.py RefactoringTool: ./Lib/ldap/sasl.py RefactoringTool: ./Lib/ldap/resiter.py RefactoringTool: ./Lib/ldap/modlist.py RefactoringTool: ./Lib/ldap/ldapobject.py RefactoringTool: ./Lib/ldap/functions.py RefactoringTool: ./Lib/ldap/filter.py RefactoringTool: ./Lib/ldap/dn.py RefactoringTool: ./Lib/ldap/controls.py RefactoringTool: ./Lib/ldap/cidict.py RefactoringTool: ./Lib/ldap/async.py RefactoringTool: ./Lib/ldap/__init__.py RefactoringTool: ./Lib/dsml.py RefactoringTool: ./Doc/conf.py RefactoringTool: ./Demo/simplebrowse.py RefactoringTool: ./Demo/simple.py RefactoringTool: ./Demo/schema_tree.py RefactoringTool: ./Demo/schema.py RefactoringTool: ./Demo/sasl_bind.py RefactoringTool: ./Demo/resiter.py RefactoringTool: ./Demo/rename.py RefactoringTool: ./Demo/reconnect.py RefactoringTool: ./Demo/pyasn1/prereadcontrol.py RefactoringTool: ./Demo/pickle_ldapobject.py RefactoringTool: ./Demo/passwd_ext_op.py RefactoringTool: ./Demo/page_control.py RefactoringTool: ./Demo/options.py RefactoringTool: ./Demo/ms_ad_bind.py RefactoringTool: ./Demo/matchedvalues.py RefactoringTool: ./Demo/ldapcontrols.py RefactoringTool: ./Demo/initialize.py RefactoringTool: ./Demo/Lib/ldif/ldifcopy.py RefactoringTool: ./Demo/Lib/ldapurl/urlsearch.py RefactoringTool: ./Demo/Lib/ldap/async/sizelimit.py RefactoringTool: ./Demo/Lib/ldap/async/ldifwriter.py RefactoringTool: ./Demo/Lib/ldap/async/deltree.py ################## +print("""################################################################## # LDAPv3 connection with StartTLS ################################################################## -""" +""") # Create LDAPObject instance l = ldap.initialize('ldap://localhost:1390',trace_level=ldapmodule_trace_level,trace_file=ldapmodule_trace_file) @@ -52,10 +52,10 @@ # Close connection l.unbind_s() -print """################################################################## +print("""################################################################## # LDAPv3 connection over SSL ################################################################## -""" +""") # Create LDAPObject instance l = ldap.initialize('ldaps://localhost:1391',trace_level=ldapmodule_trace_level,trace_file=ldapmodule_trace_file) @@ -75,10 +75,10 @@ # Close connection l.unbind_s() -print """################################################################## +print("""################################################################## # LDAPv3 connection over Unix domain socket ################################################################## -""" +""") # Create LDAPObject instance l = ldap.initialize('ldapi://%2ftmp%2fopenldap-socket',trace_level=ldapmodule_trace_level,trace_file=ldapmodule_trace_file) --- ./Demo/Lib/ldapurl/urlsearch.py (original) +++ ./Demo/Lib/ldapurl/urlsearch.py (refactored) @@ -9,24 +9,24 @@ try: ldapUrl = ldapurl.LDAPUrl(ldapUrl=sys.argv[1]) except IndexError: - print 'Usage: %s [LDAP URL]' % (sys.argv[0]) + print('Usage: %s [LDAP URL]' % (sys.argv[0])) sys.exit(1) for a in [ 'urlscheme','hostport','dn','attrs','scope', 'filterstr','extensions','who','cred' ]: - print a,repr(getattr(ldapUrl,a)) + print(a,repr(getattr(ldapUrl,a))) l = ldap.initialize(ldapUrl.initializeUrl(),trace_level=1) if ldapUrl.who!=None: if ldapUrl.cred!=None: cred=ldapUrl.cred else: - print 'Enter password for simple bind with',repr(ldapUrl.who) + print('Enter password for simple bind with',repr(ldapUrl.who)) cred=getpass.getpass() l.simple_bind_s(ldapUrl.who,cred) res = l.search_s(ldapUrl.dn,ldapUrl.scope,ldapUrl.filterstr,ldapUrl.attrs) -print len(res),'search results' +print(len(res),'search results') --- ./Demo/Lib/ldap/async/deltree.py (original) +++ ./Demo/Lib/ldap/async/deltree.py (refactored) @@ -15,7 +15,7 @@ def startSearch(self,searchRoot,searchScope): if not searchScope in [ldap.SCOPE_ONELEVEL,ldap.SCOPE_SUBTREE]: - raise ValueError, "Parameter searchScope must be either ldap.SCOPE_ONELEVEL or ldap.SCOPE_SUBTREE." + raise ValueError("Parameter searchScope must be either ldap.SCOPE_ONELEVEL or ldap.SCOPE_SUBTREE.") self.nonLeafEntries = [] self.deletedEntries = 0 ldap.async.AsyncSearchHandler.startSearch( @@ -28,7 +28,7 @@ ) def _processSingleResult(self,resultType,resultItem): - if self._entryResultTypes.has_key(resultType): + if resultType in self._entryResultTypes: # Don't process search references dn,entry = resultItem hasSubordinates = entry.get( @@ -45,7 +45,7 @@ else: try: self._l.delete_s(dn) - except ldap.NOT_ALLOWED_ON_NONLEAF,e: + except ldap.NOT_ALLOWED_ON_NONLEAF as e: self.nonLeafEntries.append(dn) else: self.deletedEntries = self.deletedEntries+1 @@ -62,7 +62,7 @@ non_leaf_entries = leafs_deleter.nonLeafEntries[:] while non_leaf_entries: dn = non_leaf_entries.pop() - print deleted_entries,len(non_leaf_entries),dn + print(deleted_entries,len(non_leaf_entries),dn) leafs_deleter.startSearch(dn,ldap.SCOPE_SUBTREE) leafs_deleter.processResults() deleted_entries = deleted_entries+leafs_deleter.deletedEntries + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.26998 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd python-ldap-2.3.13 + export LC_ALL=en_US.UTF-8 + LC_ALL=en_US.UTF-8 + CFLAGS='-pipe -Wall -g -O2 -I/usr/include/sasl' + export CFLAGS + CXXFLAGS='-pipe -Wall -g -O2 -I/usr/include/sasl' + export CXXFLAGS + FFLAGS='-pipe -Wall -g -O2 -I/usr/include/sasl' + export FFLAGS + python3 setup.py build --debug extra_compile_args: extra_objects: include_dirs: /usr/local/openldap-2.3/include /usr/include/sasl library_dirs: /usr/local/openldap-2.3/lib libs: ldap_r lber sasl2 ssl crypto running build running build_py file Lib/ldap.py (for module ldap) not found file Lib/ldap/schema.py (for module ldap.schema) not found creating build creating build/lib.linux-x86_64-3.5 copying Lib/ldapurl.py -> build/lib.linux-x86_64-3.5 copying Lib/ldif.py -> build/lib.linux-x86_64-3.5 copying Lib/dsml.py -> build/lib.linux-x86_64-3.5 creating build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/__init__.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/async.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/controls.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/cidict.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/dn.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/filter.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/functions.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/ldapobject.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/modlist.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/resiter.py -> build/lib.linux-x86_64-3.5/ldap copying Lib/ldap/sasl.py -> build/lib.linux-x86_64-3.5/ldap creating build/lib.linux-x86_64-3.5/ldap/schema copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-3.5/ldap/schema copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-3.5/ldap/schema copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-3.5/ldap/schema copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-3.5/ldap/schema file Lib/ldap.py (for module ldap) not found file Lib/ldap/schema.py (for module ldap.schema) not found running build_ext building '_ldap' extension creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/Modules x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.5/Modules/LDAPObject.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/ldapcontrol.c -o build/temp.linux-x86_64-3.5/Modules/ldapcontrol.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/common.c -o build/temp.linux-x86_64-3.5/Modules/common.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/constants.c -o build/temp.linux-x86_64-3.5/Modules/constants.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/errors.c -o build/temp.linux-x86_64-3.5/Modules/errors.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/functions.c -o build/temp.linux-x86_64-3.5/Modules/functions.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/schema.c -o build/temp.linux-x86_64-3.5/Modules/schema.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/ldapmodule.c -o build/temp.linux-x86_64-3.5/Modules/ldapmodule.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/message.c -o build/temp.linux-x86_64-3.5/Modules/message.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/version.c -o build/temp.linux-x86_64-3.5/Modules/version.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/options.c -o build/temp.linux-x86_64-3.5/Modules/options.o x86_64-alt-linux-gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Wall -g -O2 -I/usr/include/sasl -fPIC -g -DHAVE_LIBLDAP_R -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=2.3.13 -IModules -I/usr/local/openldap-2.3/include -I/usr/include/sasl -I/usr/include/python3.5m -c Modules/berval.c -o build/temp.linux-x86_64-3.5/Modules/berval.o x86_64-alt-linux-gcc -pthread -shared -pipe -Wall -g -O2 -I/usr/include/sasl -g build/temp.linux-x86_64-3.5/Modules/LDAPObject.o build/temp.linux-x86_64-3.5/Modules/ldapcontrol.o build/temp.linux-x86_64-3.5/Modules/common.o build/temp.linux-x86_64-3.5/Modules/constants.o build/temp.linux-x86_64-3.5/Modules/errors.o build/temp.linux-x86_64-3.5/Modules/functions.o build/temp.linux-x86_64-3.5/Modules/schema.o build/temp.linux-x86_64-3.5/Modules/ldapmodule.o build/temp.linux-x86_64-3.5/Modules/message.o build/temp.linux-x86_64-3.5/Modules/version.o build/temp.linux-x86_64-3.5/Modules/options.o build/temp.linux-x86_64-3.5/Modules/berval.o -L/usr/local/openldap-2.3/lib -Wl,--enable-new-dtags,-R/usr/local/openldap-2.3/lib -lldap_r -llber -lsasl2 -lssl -lcrypto -lm -o build/lib.linux-x86_64-3.5/_ldap.cpython-35m.so + exit 0 Executing(%install): /bin/sh -e /usr/src/tmp/rpm-tmp.75470 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + /bin/chmod -Rf u+rwX -- /usr/src/tmp/python3-module-ldap-buildroot + : + /bin/rm -rf -- /usr/src/tmp/python3-module-ldap-buildroot + cd python-ldap-2.3.13 + export LC_ALL=en_US.UTF-8 + LC_ALL=en_US.UTF-8 + python3 setup.py install --skip-build --root=/usr/src/tmp/python3-module-ldap-buildroot --force extra_compile_args: extra_objects: include_dirs: /usr/local/openldap-2.3/include /usr/include/sasl library_dirs: /usr/local/openldap-2.3/lib libs: ldap_r lber sasl2 ssl crypto running install running install_lib creating /usr/src/tmp/python3-module-ldap-buildroot creating /usr/src/tmp/python3-module-ldap-buildroot/usr creating /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64 creating /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3 creating /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages copying build/lib.linux-x86_64-3.5/_ldap.cpython-35m.so -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages creating /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap creating /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema copying build/lib.linux-x86_64-3.5/ldap/schema/tokenizer.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema copying build/lib.linux-x86_64-3.5/ldap/schema/subentry.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema copying build/lib.linux-x86_64-3.5/ldap/schema/models.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema copying build/lib.linux-x86_64-3.5/ldap/schema/__init__.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema copying build/lib.linux-x86_64-3.5/ldap/sasl.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/resiter.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/modlist.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/ldapobject.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/functions.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/filter.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/dn.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/cidict.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/controls.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/async.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/ldap/__init__.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap copying build/lib.linux-x86_64-3.5/dsml.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages copying build/lib.linux-x86_64-3.5/ldif.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages copying build/lib.linux-x86_64-3.5/ldapurl.py -> /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema/tokenizer.py to tokenizer.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema/subentry.py to subentry.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema/models.py to models.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/schema/__init__.py to __init__.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/sasl.py to sasl.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/resiter.py to resiter.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/modlist.py to modlist.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/ldapobject.py to ldapobject.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/functions.py to functions.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/filter.py to filter.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/dn.py to dn.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/cidict.py to cidict.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/controls.py to controls.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/async.py to async.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldap/__init__.py to __init__.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/dsml.py to dsml.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldif.py to ldif.cpython-35.pyc byte-compiling /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/ldapurl.py to ldapurl.cpython-35.pyc writing byte-compilation script '/usr/src/tmp/tmpifydm8lt.py' /usr/bin/python3 -O /usr/src/tmp/tmpifydm8lt.py removing /usr/src/tmp/tmpifydm8lt.py running install_egg_info Writing /usr/src/tmp/python3-module-ldap-buildroot/usr/lib64/python3/site-packages/python_ldap-2.3.13-py3.5.egg-info + /usr/lib/rpm/brp-alt Cleaning files in /usr/src/tmp/python3-module-ldap-buildroot (auto) mode of './usr/lib64/python3/site-packages/_ldap.cpython-35m.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--) Verifying and fixing files in /usr/src/tmp/python3-module-ldap-buildroot (binconfig,pkgconfig,libtool,desktop) Compressing files in /usr/src/tmp/python3-module-ldap-buildroot (auto) Adjusting library links in /usr/src/tmp/python3-module-ldap-buildroot ./usr/lib64: Verifying ELF objects in /usr/src/tmp/python3-module-ldap-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal) verify-elf: ERROR: ./usr/lib64/python3/site-packages/_ldap.cpython-35m.so: RPATH contains illegal absolute entry "/usr/local/openldap-2.3/lib": /usr/local/openldap-2.3/lib error: Bad exit status from /usr/src/tmp/rpm-tmp.75470 (%install) RPM build errors: Bad exit status from /usr/src/tmp/rpm-tmp.75470 (%install) Command exited with non-zero status 1 7.23user 0.58system 0:08.92elapsed 87%CPU (0avgtext+0avgdata 54724maxresident)k 0inputs+0outputs (0major+171117minor)pagefaults 0swaps hsh-rebuild: rebuild of `python3-module-ldap-2.3.13-alt1.1.src.rpm' failed. Command exited with non-zero status 1 19.02user 3.40system 0:24.37elapsed 92%CPU (0avgtext+0avgdata 124740maxresident)k 144inputs+0outputs (0major+481895minor)pagefaults 0swaps