ipaldap, ldapupdate: Encoding fixes for Python 3

https://fedorahosted.org/freeipa/ticket/5638

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Petr Viktorin
2016-02-17 10:41:29 +01:00
committed by Jan Cholasta
parent 831856ea55
commit fe7bd36728
2 changed files with 18 additions and 4 deletions
+10 -4
View File
@@ -346,11 +346,16 @@ class LDAPEntry(collections.MutableMapping):
return self._names[name]
if self._conn.schema is not None:
if six.PY2:
encoded_name = name.encode('utf-8')
else:
encoded_name = name
attrtype = self._conn.schema.get_obj(
ldap.schema.AttributeType, name.encode('utf-8'))
ldap.schema.AttributeType, encoded_name)
if attrtype is not None:
for altname in attrtype.names:
altname = altname.decode('utf-8')
if six.PY2:
altname = altname.decode('utf-8')
self._names[altname] = name
self._names[name] = name
@@ -774,8 +779,9 @@ class LDAPClient(object):
if not self._decode_attrs:
return bytes
if isinstance(name_or_oid, unicode):
name_or_oid = name_or_oid.encode('utf-8')
if six.PY2:
if isinstance(name_or_oid, unicode):
name_or_oid = name_or_oid.encode('utf-8')
# Is this a special case attribute?
if name_or_oid in self._SYNTAX_OVERRIDE: