[server/ldap] deal with unicode or str coming out of ldap
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 19 Nov 2015 15:56:22 +0100
changeset 10844 f3007bbd77e9
parent 10843 580a6821713d
child 10845 75c60e58ce6b
[server/ldap] deal with unicode or str coming out of ldap It seems we can get either, I've no idea in which exact circumstances, so this should let us work with both.
server/sources/ldapfeed.py
--- a/server/sources/ldapfeed.py	Thu Nov 19 14:36:54 2015 +0100
+++ b/server/sources/ldapfeed.py	Thu Nov 19 15:56:22 2015 +0100
@@ -338,7 +338,7 @@
             elif self.user_attrs.get(key) == 'modification_date':
                 itemdict[key] = datetime.strptime(value[0], '%Y%m%d%H%M%SZ')
             else:
-                if PY2:
+                if PY2 and value and isinstance(value[0], str):
                     value = [unicode(val, 'utf-8', 'replace') for val in value]
                 if len(value) == 1:
                     itemdict[key] = value = value[0]