Hi all, Anyone got any idea what this means: argument 1: expected string without null bytes, string found I would send the traceback but this is happening in a few places, various places which seem to have no connection except that they are all External Methods. I'm stumped. tia Phil phil.harris@zope.co.uk
Phil Harris wrote:
Hi all,
Anyone got any idea what this means:
argument 1: expected string without null bytes, string found
The line throwing this error and the declaration line of the function being called would be handy... cheers, Chris
Chris/all, as requested by ChrisW def auth_LDAP(self,cn=None,pwd=None): if cn==None or pwd==None: return None l=ldap.open('medico.uwcm.ac.uk') cn='cn='+cn l.search_s('',ldap.SCOPE_SUBTREE,cn) # this is where it fails res=l.result() auth=[res[1][0][0],pwd] l.simple_bind_s(auth[0],auth[1]) l.unbind_s() return 1 It's basically trying to : 1. do an anonymous bind to an LDAP server to find the dn of a particular user 2. take the dn returned and then try to authenticate that user but it don't get that far. (I know there is no error trapping etc. I took it out to see what exactly was happening.) It always fails on the l.search_s, the cn and the pwd are returned from a form (actually the login form of LoginManager). I know the function works when not called from Zope but I really can't see how that could possibly matter. Any ideas? Phil ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Phil Harris" <phil.harris@zope.co.uk> Cc: <zope@zope.org> Sent: Tuesday, February 27, 2001 12:47 PM Subject: Re: [Zope] Strange error/traceback
Phil Harris wrote:
Hi all,
Anyone got any idea what this means:
argument 1: expected string without null bytes, string found
The line throwing this error and the declaration line of the function being called would be handy...
cheers,
Chris
l=ldap.open('medico.uwcm.ac.uk') cn='cn='+cn
can you stick a print ldap.SCOP_SUBTREE in here?
l.search_s('',ldap.SCOPE_SUBTREE,cn) # this is where it fails res=l.result() auth=[res[1][0][0],pwd] l.simple_bind_s(auth[0],auth[1]) l.unbind_s() return 1
argument 1: expected string without null bytes, string found
This sounds like argument 1 contains something like 'sample\000' and search_s doesn't like it. I wonder if there's a null terminated string coming back from a C function somewhere? *stab*, nope, it's still dark in here ;-) Chris
Chris, It's slightly more insidious than that. The thing it was complaining about was the '' (empty string) on the line where the error occurred. Strange thing is it only complains when run in Zope not from straight Python. Seems as if Zope is doing something with empty strings (I've got no proof of that thoug as they look/feel the same when printed/debugged etc). This isn't the first time I've seen this though, it's happened various times in various ExternalMethods (last time was a call into PyXML). The LDAP_SCOPETREE is an integer type btw. Any way, problem solved by doing this: res=l.search_s('o=CM',ldap.SCOPE_SUBTREE,arg_cn) if len(res) == 0: res=l.search_s('o=CF',ldap.SCOPE_SUBTREE,arg_cn) if len(res) == 0: raise 'Invalid credentials' But I'm lucky in that our LDAP server has only 2 main trees, things would have been interesting if it had more ;) Lucky thing is that most users are in the CM tree, so this actually speeded things up quite dramatically. Anyway, thanks for trying to help. See ya Phil phil.harris@zweb.co.uk ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Phil Harris" <phil.harris@zope.co.uk> Cc: <zope@zope.org> Sent: Tuesday, February 27, 2001 7:03 PM Subject: Re: [Zope] Strange error/traceback
l=ldap.open('medico.uwcm.ac.uk') cn='cn='+cn
can you stick a print ldap.SCOP_SUBTREE in here?
l.search_s('',ldap.SCOPE_SUBTREE,cn) # this is where it fails res=l.result() auth=[res[1][0][0],pwd] l.simple_bind_s(auth[0],auth[1]) l.unbind_s() return 1
argument 1: expected string without null bytes, string found
This sounds like argument 1 contains something like 'sample\000' and search_s doesn't like it. I wonder if there's a null terminated string coming back from a C function somewhere?
*stab*, nope, it's still dark in here ;-)
Chris
participants (2)
-
Chris Withers -
Phil Harris