[python-ldap] [BUG] KeyError on 'errno'
Matt Bosworth
matt at codetastic.com
Thu May 25 15:59:58 EDT 2017
My bad! The error is actually in pyldap, which merged in python-ldap
2.4.35 a few weeks ago
It appears that pyldap and python-ldap are stomping on each other. I'm
using django-auth-ldap, which pulls in python-ldap, but I'm also pulling in
pyldap from another (internal) library. And since they both sit in
site-packages/ldap/ I mistakenly thought python-ldap was the issue.
Apologies! I'll go pester the other project :)
Cheers,
Matt
On Thu, May 25, 2017 at 2:16 AM, Michael Ströder <michael at stroeder.com>
wrote:
> Matt Bosworth wrote:
> > It looks like this might be a regression that snuck back in over the
> last couple
> > weeks?
> >
> > I just updated to the latest version of python-ldap (2.4.38),
> django-auth-ldap
> > (1.2.12), and django (1.11.1) and now successful LDAP authentication
> raises an Exception
> > (full stack trace below).
> >
> > Rolling back to 2.4.37 fixes the issue.
>
> Hmm, are you sure with the versions?
>
> I'm asking because there wasn't any change in Lib/ldap/ from 2.4.37 to
> 2.4.38 (check
> CHANGES):
>
> ---------------------------------- snip ------------------------------
> ------
> $ diff -ur python-ldap-2.4.37/Lib/ldap python-ldap-2.4.38/Lib/ldap
> diff -ur python-ldap-2.4.37/Lib/ldap/__init__.py
> python-ldap-2.4.38/Lib/ldap/__init__.py
> --- python-ldap-2.4.37/Lib/ldap/__init__.py 2017-04-26
> 22:48:43.000000000 +0200
> +++ python-ldap-2.4.38/Lib/ldap/__init__.py 2017-04-27
> 13:11:01.000000000 +0200
> @@ -3,12 +3,12 @@
>
> See http://www.python-ldap.org/ for details.
>
> -$Id: __init__.py,v 1.115 2017/04/26 20:48:43 stroeder Exp $
> +$Id: __init__.py,v 1.116 2017/04/27 11:11:01 stroeder Exp $
> """
>
> # This is also the overall release version number
>
> -__version__ = '2.4.37'
> +__version__ = '2.4.38'
>
> import sys
> ---------------------------------- snip ------------------------------
> ------
>
> > Traceback:
> > [..]
> > "/Users/bosworth/Documents/git/RtDjango/venv-py27/lib/
> python2.7/site-packages/ldap/ldapobject.py"
> > in _ldap_call
> > 273. e.args[0]['info'] = strerror(e.args[0]['errno'])
> >
> > Exception Type: KeyError at /login/
> > Exception Value: u'errno'
>
> The error you experienced was fixed in 2.4.37 as noted in CHANGES (see the
> Lib/ldap/ diff
> from 2.4.35 to 2.4.38 attached below). Are you sure that you have tested a
> clean
> installation of 2.4.38 in your virtualenv? I suspect that your downgrade
> to 2.4.37 has
> overwritten some left-overs from 2.4.35 installation.
>
> Ciao, Michael.
>
> ---------------------------------- snip ------------------------------
> ------
> --- python-ldap-2.4.35/Lib/ldap/__init__.py 2017-04-25
> 15:52:48.000000000 +0200
> +++ python-ldap-2.4.38/Lib/ldap/__init__.py 2017-04-27
> 13:11:01.000000000 +0200
> @@ -3,12 +3,12 @@
>
> See http://www.python-ldap.org/ for details.
>
> -$Id: __init__.py,v 1.113 2017/04/25 13:52:48 stroeder Exp $
> +$Id: __init__.py,v 1.116 2017/04/27 11:11:01 stroeder Exp $
> """
>
> # This is also the overall release version number
>
> -__version__ = '2.4.35'
> +__version__ = '2.4.38'
>
> import sys
>
> diff -ur python-ldap-2.4.35/Lib/ldap/ldapobject.py
> python-ldap-2.4.38/Lib/ldap/ldapobject.py
> --- python-ldap-2.4.35/Lib/ldap/ldapobject.py 2017-04-25
> 15:44:47.000000000 +0200
> +++ python-ldap-2.4.38/Lib/ldap/ldapobject.py 2017-04-27
> 10:40:10.000000000 +0200
> @@ -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.162 2017/04/27 08:40:10 stroeder Exp $
>
> Compability:
> - Tested with Python 2.0+ but should work with Python 1.5.x
> @@ -111,9 +111,9 @@
> diagnostic_message_success = self._l.get_option(ldap.OPT_
> DIAGNOSTIC_MESSAGE)
> finally:
> self._ldap_object_lock.release()
> - except LDAPError,e:
> - if 'info' not in e.args[0]:
> - e.args[0]['info'] = strerror(e.args[0]['errno'])
> + except LDAPError, e:
> + if not e.args[0].has_key('info') and e.args[0].has_key('errno'):
> + 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170525/909b8105/attachment.html>
More information about the python-ldap
mailing list