SVN: ldapadapter/trunk/utility.py Not all data is encoded unicode; some is binary, so leave it alone. Note

Stephan Richter <[email protected]>
Newsgroups gmane.comp.web.zope.public-cvs
Message-ID <[email protected]>
Log message for revision 30469:
  Not all data is encoded unicode; some is binary, so leave it alone. Note 
  that I found this bug by working with a real LDAP database.
  

Changed:
  U   ldapadapter/trunk/utility.py

-=-
Modified: ldapadapter/trunk/utility.py
===================================================================
--- ldapadapter/trunk/utility.py	2005-05-20 17:43:15 UTC (rev 30468)
+++ ldapadapter/trunk/utility.py	2005-05-20 17:56:28 UTC (rev 30469)
@@ -139,7 +139,11 @@
             for key, values in entry.items():
                 # TODO: Can key be non-ascii? Check LDAP spec.
                 # FIXME: there may be non-textual binary values.
-                values[:] = [unicode(v, 'utf-8') for v in values]
+                try:
+                    values[:] = [unicode(v, 'utf-8') for v in values]
+                except UnicodeDecodeError:
+                    # Not all data is unicode, so decoding does not always work.
+                    pass
             results.append((dn, entry))
         return results
 

_______________________________________________
Zope-CVS maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.