From c85f2cc9265922c67feb89f5eba94966300f2bff Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Oct 2015 12:58:14 +0200 Subject: [PATCH] [Py3] schema: Decode schema elements to str when loading Fixes https://github.com/pyldap/pyldap/issues/11 --- Lib/ldap/schema/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/ldap/schema/models.py b/Lib/ldap/schema/models.py index e017041..afab124 100644 --- a/Lib/ldap/schema/models.py +++ b/Lib/ldap/schema/models.py @@ -33,6 +33,7 @@ class SchemaElement: schema_element_str String which contains the schema element description to be parsed. + (Bytestrings are decoded using UTF-8) Class attributes: @@ -47,6 +48,8 @@ class SchemaElement: } def __init__(self,schema_element_str=None): + if sys.version_info >= (3, 0) and isinstance(schema_element_str, bytes): + schema_element_str = schema_element_str.decode('utf-8') if schema_element_str: l = split_tokens(schema_element_str,self.token_defaults) self.set_id(l[1])