Bug: urllib2 basic authentication does not trap auth failure in windows?

naugiedoggie michael.a.powe at gmail.com
Sat Sep 11 16:29:19 EDT 2010


Hello,

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
retries.

Here's a note from the urllib2.py code:

<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
failed",
                            headers, None)
</code>

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.

Thanks.

mp



More information about the Python-list mailing list