From a010386a23b52ad8cde48da7a5cffa1a912dd0c1 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 2 Mar 2011 10:29:38 +0000 Subject: [PATCH] finally a proper fix for that annoying recursive bug --- lib/request/basicauthhandler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/request/basicauthhandler.py b/lib/request/basicauthhandler.py index eac1faceb..eb351968d 100644 --- a/lib/request/basicauthhandler.py +++ b/lib/request/basicauthhandler.py @@ -29,5 +29,12 @@ class SmartHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): if hash(req) not in self.retried_req: self.retried_req.add(hash(req)) self.retried = 0 + else: + if self.retried > 5: + raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed", + headers, None) + else: + self.retried += 1 + return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed( self, auth_header, host, req, headers)