pyldap / pyldap

THIS FORK IS DEPRECATED; development moved to python-ldap
https://github.com/python-ldap/python-ldap
Other
105 stars 34 forks source link

errno-related timeout raises non-LDAPError #124

Closed malthe closed 6 years ago

malthe commented 6 years ago

In case an IndexError is raised _ldap_call, the current logic does not re-raise the LDAPError but instead the IndexError breaking expectations further up.

See d8ac99c3c376ab6d3379b233acb7747db8dedd4f.

darkrain42 commented 6 years ago

Note that this issue only appears to occur in Python 2 (or, at least, Python 3.6 re-raises the original exception, not the last one).

It seems like there are two possible fixes here:

  1. Rewrite the offending if 'info'... line to check that len(args) > 0 (or something as simple as if e.args and 'info' not in ...), and then remove the try / except.

  2. Adopt/adapt the upstream fix, but update for Python 3.

Python 3's raise syntax is different, and the Python 2 syntax will raise a SyntaxError even if you condition it on the Python version. The ideal way to do that would be to have pyldap add a dependency on six and just use six.reraise.

encukou commented 6 years ago

I'll adapt upstream fix as soon as I get to merging python-ldap 2.4.45.