SOLVED: Re: Trap Authentication Errors in HTTP Request

naugiedoggie michael.a.powe at
Sat Sep 11 22:00:22 CEST 2010

On Sep 10, 12:09 pm, naugiedoggie <michael.a.p... at> wrote:
> Hello,
> I have a script that authenticates to a web service provider to
> retrieve data.  This script provides an authentication header built in
> a very basic way like this:

The answer is that there is something whacked in the Windoze
implementation for urllib2.

It turns out that the script works fine when run in a linux console.
'401' error is trapped as expected by an exception handler.  In
Winblows, the builtin handler for authentication is supposed to take a
dump after 5 retries, but this seems to not happen.  The retries
continue until a recursion exception is fired.  At this point the
script dumps back to the console.  An exception handler for Exception
will catch this.



More information about the Python-list mailing list