[python-ldap] Reraising wrong exception in _ldap_call()
aigars.grins at sentor.se
Tue Sep 26 03:00:08 EDT 2017
In ldap.ldapobject theres a method called SimpleLDAPObject._ldap_call().
In it there's error handling code along the lines of (abbreviated here):
result = func(*args, **kwargs)
except LDAPError, e:
if not e.args.has_key('info') and e.args.has_key('errno'):
e.args['info'] = strerror(e.args['errno'])
This means that if the raised LDAPError was e.g. a TIMEOUT w/o any args,
then the `e.args` will raise an IndexError. That will be caught,
which is fine. But then the reraise will reraise not the LDAPError but
So the `raise` should be replaced with `raise e`.
The way I found this was by running something along the lines of:
msgid = cnxn.search_ext(base, scope, ..., timeout = 0.00001)
cnxn.result(msgid, timeout = 0.00001)
The short timeouts triggers a TIMEOUT, but it doesn't have any args.
More information about the python-ldap