UnicodeEncodeError: 'latin-1' codec can't encode characters in position 3-4: ordinal not in range(256)

Bug #898921 reported by adam tang
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Products.LDAPUserFolder
Invalid
Low
Unassigned

Bug Description

I use plone.app.ldap integrate AD to Plone4.1.3,when login using a chinese accoutname ,throw out the following error:

2011-12-01 20:55:40 ERROR event.LDAPDelegate 'latin-1' codec can't encode characters in position 3-4: ordinal not in range(256)
Traceback (most recent call last):
File "/home/panlei/plone41/eggs/Products.LDAPUserFolder-2.19-py2.6.egg/Products/LDAPUserFolder/LDAPDelegate.py", line 403, in search
rec_dict['dn'] = from_utf8(rec_dn)
File "/home/panlei/plone41/eggs/Products.LDAPUserFolder-2.19-py2.6.egg/Products/LDAPUserFolder/utils.py", line 111, in from_utf8
return encodeLocal(decodeUTF8(s)[0])[0]
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 3-4: ordinal not in range(256)
> /home/panlei/plone41/eggs/Products.LDAPUserFolder-2.19-py2.6.egg/Products/LDAPUserFolder/utils.py(111)from_utf8()
-> return encodeLocal(decodeUTF8(s)[0])[0]

http://pastie.org/2952590

Revision history for this message
adam tang (yuejun-tang) wrote :

The bug was fixed by under process:
/home/panlei/plone41/eggs/Products.LDAPUserFolder-2.20-py2.6.egg/Products/LDAPUserFolder/utils.py
64 line: encoding = 'latin1' to encoding = 'utf-8'

Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

Changing the encoding in utils.py is the correct solution, which you already found.

Changed in ldapuserfolder:
assignee: nobody → Jens Vagelpohl (dataflake)
importance: Undecided → Low
status: New → Invalid
Revision history for this message
J M Cerqueira Esteves (jmce) wrote :

Having been bitten by the same issue [solved it the same way as described above], curious on the change to Importance=Low, status=Invalid. Lacking other means to solve it, shouldn't at least the above tip be part of documentation? (Or (quite possible) maybe I'm unaware of some other information which in general should make all this less relevant...)

Revision history for this message
RĂ©gis Rouet (regis-rouet) wrote :

Agree with previous comment.
'utf-8' seems a more adequate default in 2014.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.