diff -r 8f0df4db2b06 Lib/urllib/request.py --- a/Lib/urllib/request.py Tue Sep 27 15:23:04 2016 -0700 +++ b/Lib/urllib/request.py Tue Sep 27 18:53:29 2016 -0500 @@ -1059,12 +1059,13 @@ # XXX qop="auth-int" supports is shaky - def __init__(self, passwd=None): + def __init__(self, passwd=None, retry_count=5): if passwd is None: passwd = HTTPPasswordMgr() self.passwd = passwd self.add_password = self.passwd.add_password self.retried = 0 + self.retry_count = int(retry_count) self.nonce_count = 0 self.last_nonce = None @@ -1073,7 +1074,7 @@ def http_error_auth_reqed(self, auth_header, host, req, headers): authreq = headers.get(auth_header, None) - if self.retried > 5: + if self.retried > self.retry_count: # Don't fail endlessly - if we failed once, we'll probably # fail a second time. Hm. Unless the Password Manager is # prompting for the information. Crap. This isn't great