[python-ldap] § in passwords

Michael Ströder michael at stroeder.com
Thu Sep 29 15:30:32 EDT 2016


Andreas Stenius wrote:
> I seem to have run into a bug in python-ldap. I have a user who consistently
> fail to login, but for "everyone" else it works just fine.
> 
> After some troubleshooting, I became aware of his password containing a §-sign.
> [..]
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xa7' in position 5:
> ordinal not in range(128)

Yupp.

Python 2.7.12 (default, Jun 28 2016, 06:57:42) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> u'§'.encode('ascii')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa7' in position 0:
ordinal not in range(128)
>>> u'§'.encode('utf-8')
'\xc2\xa7'

python-ldap only accepts binary strings.
=> Your application has to invoke .encode('utf-8').

Ciao, Michael.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3829 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160929/c3b9d4f2/attachment.bin>


More information about the python-ldap mailing list