Blob Blame History Raw
diff -up Python-2.6.6/Lib/urllib2.py.fix-urllib2-AbstractBasicAuthHandler Python-2.6.6/Lib/urllib2.py
--- Python-2.6.6/Lib/urllib2.py.fix-urllib2-AbstractBasicAuthHandler	2011-01-19 15:41:41.254656156 -0500
+++ Python-2.6.6/Lib/urllib2.py	2011-01-19 15:41:41.338791514 -0500
@@ -823,6 +823,9 @@ class AbstractBasicAuthHandler:
         self.add_password = self.passwd.add_password
         self.retried = 0
 
+    def reset_retry_count(self):
+        self.retried = 0
+
     def http_error_auth_reqed(self, authreq, host, req, headers):
         # host may be an authority (without userinfo) or a URL with an
         # authority
@@ -862,8 +865,10 @@ class HTTPBasicAuthHandler(AbstractBasic
 
     def http_error_401(self, req, fp, code, msg, headers):
         url = req.get_full_url()
-        return self.http_error_auth_reqed('www-authenticate',
-                                          url, req, headers)
+        response = self.http_error_auth_reqed('www-authenticate',
+                                              url, req, headers)
+        self.reset_retry_count()
+        return response
 
 
 class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
@@ -876,8 +881,10 @@ class ProxyBasicAuthHandler(AbstractBasi
         # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
         # userinfo.
         authority = req.get_host()
-        return self.http_error_auth_reqed('proxy-authenticate',
+        response = self.http_error_auth_reqed('proxy-authenticate',
                                           authority, req, headers)
+        self.reset_retry_count()
+        return response
 
 
 def randombytes(n):