[pypy-dev] using python-ldap under pypy
elmir at unity3d.com
Sun Dec 13 16:19:47 EST 2015
On Fri, Dec 11, 2015 at 3:39 PM, Maciej Fijalkowski <fijall at gmail.com>
> Hi Elmir.
> I would say that it should work, however, subtle bugs are a bit expected.
> Cool! We should try to fix the bug!
> I'm happy to help you debug it, let me know how I can reproduce it.
The bug is pretty simple to reproduce, basically doing this query will show
l = ldap.initialize(SERVER)
res = l.search_s(BASE_DN,
["uid", "cn"]) # <-- these string will be mangled
Here is the complete script which shows the bug:
The error happens in the python-ldap C code that converts ["uid", "cn"]
array to char **.
In this file:
in function attrs_from_List() there is this code (lines 289-290):
289: attrs[i] = PyString_AsString(item);
On line 289 the assigned string is correct, however after executing line
290, the string will be corrupted.
I have noticed that under cpython, the refcount for 'item' is larger then
1. However under pypy it is always 1, and I guess after decreasing it, the
'item' is freed, and attrs[i] pointer becomes invalid.
I don't know enough about python extension C API to know if this is a
problem in python-ldap C code, or in the pypy code. Any help is appreciated!
A general question, does pypy strive to be compatible with the API defined
here: https://docs.python.org/2/c-api/ ?
Thanks in advance,
> On Fri, Dec 11, 2015 at 4:07 PM, Elmir Jagudin <elmir at unity3d.com> wrote:
> > Hi
> > I'm trying to run an application under pypy that authenticates user with
> > LDAP.
> > It is using python-ldap module and it fails to lookup the users. The
> > is in python-ldap's c extension code. When it converts the LDAP search
> > from python format to C, parts of the query are corrupted.
> > Is python-ldap supposed to work under pypy? How compatible is the python
> > API between cpython and pypy?
> > Right now I can't figure out if this is a bug in python-ldap code or an
> > compatibility with Pypy C API.
> > Regards,
> > Elmir Jagudin
> > _______________________________________________
> > pypy-dev mailing list
> > pypy-dev at python.org
> > https://mail.python.org/mailman/listinfo/pypy-dev
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pypy-dev