Bug: urllib2 basic authentication does not trap auth failure in windows?
michael.a.powe at gmail.com
Sat Sep 11 22:29:19 CEST 2010
Is this a known issue?
I have a script that authenticates to a web service. urllib2 process
for authenticating for basic auth is supposed to dump out after 5
Here's a note from the urllib2.py code:
def http_error_auth_reqed(self, auth_header, host, req, headers):
authreq = headers.get(auth_header, None)
if self.retried > 5:
# Don't fail endlessly - if we failed once, we'll probably
# fail a second time. Hm. Unless the Password Manager is
# prompting for the information. Crap. This isn't great
# but it's better than the current 'repeat until recursion
# depth exceeded' approach <wink>
raise HTTPError(req.get_full_url(), 401, "digest auth
This note is from the digest handler but the basic handler is exactly
the same in the important respects.
What happens in a windows console is that, in fact, the code dumps
with the message 'maximum recursion depth reached.'
Whereas, in the linux console, the same script exits appropriately
with the trapped 401 error that authentication failed.
More information about the Python-list