From 3a1f5744be7d3f8e216ef94672b779d3373d2861 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 2 Mar 2011 10:42:17 +0000 Subject: [PATCH] minor update to make counting variable totally independent of the urllib2's self.retried --- lib/request/basicauthhandler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/request/basicauthhandler.py b/lib/request/basicauthhandler.py index eb351968d..d73fb81cc 100644 --- a/lib/request/basicauthhandler.py +++ b/lib/request/basicauthhandler.py @@ -17,6 +17,7 @@ class SmartHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): def __init__(self, *args, **kwargs): urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs) self.retried_req = set() + self.retried_count = 0 def reset_retry_count(self): # Python 2.6.5 will call this on 401 or 407 errors and thus loop @@ -28,13 +29,13 @@ class SmartHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): # Reset the retry counter once for each request. if hash(req) not in self.retried_req: self.retried_req.add(hash(req)) - self.retried = 0 + self.retried_count = 0 else: - if self.retried > 5: + if self.retried_count > 5: raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed", headers, None) else: - self.retried += 1 + self.retried_count += 1 return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed( self, auth_header, host, req, headers)