[Python-checkins] r81637 - in python/branches/release26-maint: Lib/test/test_urllib2.py Lib/urllib2.py
senthil.kumaran
python-checkins at python.org
Tue Jun 1 14:42:45 CEST 2010
Author: senthil.kumaran
Date: Tue Jun 1 14:42:44 2010
New Revision: 81637
Log:
Merged revisions 81636 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81636 | senthil.kumaran | 2010-06-01 18:10:07 +0530 (Tue, 01 Jun 2010) | 3 lines
Fix Issue8797 - urllib2 basic authentication fix for wrong passwords. It fails after 5 retries.
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/test/test_urllib2.py
python/branches/release26-maint/Lib/urllib2.py
Modified: python/branches/release26-maint/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_urllib2.py (original)
+++ python/branches/release26-maint/Lib/test/test_urllib2.py Tue Jun 1 14:42:44 2010
@@ -1145,7 +1145,6 @@
self.assertEqual(len(http_handler.requests), 1)
self.assertFalse(http_handler.requests[0].has_header(auth_header))
-
class MiscTests(unittest.TestCase):
def test_build_opener(self):
Modified: python/branches/release26-maint/Lib/urllib2.py
==============================================================================
--- python/branches/release26-maint/Lib/urllib2.py (original)
+++ python/branches/release26-maint/Lib/urllib2.py Tue Jun 1 14:42:44 2010
@@ -819,12 +819,21 @@
password_mgr = HTTPPasswordMgr()
self.passwd = password_mgr
self.add_password = self.passwd.add_password
+ 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
# XXX could be multiple headers
authreq = headers.get(authreq, None)
+
+ if self.retried > 5:
+ # retry sending the username:password 5 times before failing.
+ raise HTTPError(req.get_full_url(), 401, "basic auth failed",
+ headers, None)
+ else:
+ self.retried += 1
+
if authreq:
mo = AbstractBasicAuthHandler.rx.search(authreq)
if mo:
More information about the Python-checkins
mailing list