Bug in LDAPObject.c, l_ldap_result()

Derrick 'dman' Hudson dman at dman.ddts.net
Sat Jun 29 19:52:44 CEST 2002


On Sat, Jun 29, 2002 at 04:32:52PM +0200, Michael Ströder wrote:
| Derrick 'dman' Hudson wrote:

| >-       pmsg = Py_None;
| >+       pmsg = LDAPmessage_to_python( self->ldap, msg );

| >It really does help to not ignore the data that's returned :-).
| 
| Oh, yes.
| 
| >I haven't thoroughly tested it
| 
| You already noticed the issues with web2ldap.

Yep.  I was beating myself over the head last night trying to figure
out the right type to return.

| One has to fix two other parts of python-ldap for this patch to work
| with web2ldap.

Ahh.
 
| I've checked in Modules/LDAPObject.c Lib/ldap/ldapobject.py 
| Lib/ldap/async.py. Now the C module's result() is directly wrapped 
| and LDAPObject.c contains the fix above.

I see now :

  def search_st(...)
-    return self.result(msgid,all=1,timeout=timeout)
+    return self.result(msgid,all=1,timeout=timeout)[1]
      

That's precisely what I kept running into -- the line
    ldap_result[0][1]
_sometimes_ wasn't getting the right element.  I thought the result
function wasn't returning the right value (it needed another layer of
list nesting), but when I would add the extra list some other parts
wouldn't work!  That certainly explains it :-).

| I guess I will add a derived class for the non-blocking version of 
| LDAPObject.result(). So everyone will be free to choose.

Isn't that what 'timeout=0' is for?  I also think the C function needs
to be modified to treat Py_None as NULL to allow python code to
specify a timeout that is indefinitely long.

-D

-- 

"GUIs normally make it simple to accomplish simple actions and
impossible to accomplish complex actions."
    --Doug Gwyn  (22/Jun/91 in comp.unix.wizards)
 
http://dman.ddts.net/~dman/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20020629/42c59628/attachment.pgp>


More information about the python-ldap mailing list