Skip to content

Commit

Permalink
gracefully handle KeyError in LDAPObject._ldap_call() when using errno
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Apr 25, 2017
1 parent b6e068b commit dbb85b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
----------------------------------------------------------------
Released 2.4.36 2017-04-26

Changes since 2.4.35:

Lib/
* gracefully handle KeyError in LDAPObject._ldap_call() when
using errno

----------------------------------------------------------------
Released 2.4.35 2017-04-25

Expand Down Expand Up @@ -1374,4 +1383,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.423 2017/04/25 17:42:00 stroeder Exp $
$Id: CHANGES,v 1.424 2017/04/25 17:50:33 stroeder Exp $
9 changes: 7 additions & 2 deletions Lib/ldap/ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
\$Id: ldapobject.py,v 1.160 2017/04/25 13:40:52 stroeder Exp $
\$Id: ldapobject.py,v 1.161 2017/04/25 17:50:33 stroeder Exp $
Compability:
- Tested with Python 2.0+ but should work with Python 1.5.x
Expand Down Expand Up @@ -113,7 +113,12 @@ def _ldap_call(self,func,*args,**kwargs):
self._ldap_object_lock.release()
except LDAPError,e:
if 'info' not in e.args[0]:
e.args[0]['info'] = strerror(e.args[0]['errno'])
try:
errno = e.args[0]['errno']
except KeyError:
pass
else:
e.args[0]['info'] = strerror(e.args[0]['errno'])
if __debug__ and self._trace_level>=2:
self._trace_file.write('=> LDAPError - %s: %s\n' % (e.__class__.__name__,str(e)))
raise
Expand Down

0 comments on commit dbb85b1

Please sign in to comment.