python-ldap “expected a string in the list”

This error is given by python-ldap on Python 2.x on certain operations when it receives unicode objects where it expects a str object. Make sure any strings you pass into python-ldap are string type, not unicode type, and this problem will go away.  🙂

6 thoughts on “python-ldap “expected a string in the list”

  1. Yep, you’ve saved my time! Thank you!

    def u2s(x):
    if isinstance(x, list):
    return [ADChecker.u2s(y) for y in x]
    if isinstance(x, dict):
    r = dict()
    for y in x.keys():
    r[ADChecker.u2s(y)] = ADChecker.u2s(x[y])
    return r
    if isinstance(x, unicode):
    return str(x)
    return x

    def search_s(cls, *args, **kwargs):
    return*ADChecker.u2s(args), **ADChecker.u2s(kwargs))

Leave a Reply

Your email address will not be published. Required fields are marked *