This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: urllib2's AbstractBasicAuthHandler is limited to 6 requests
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: mark.dickinson, mhuewe, orsenthil
Priority: normal Keywords: patch

Created on 2010-08-19 09:11 by mhuewe, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
urllib2-AbstractBasicAuthHandler_reset_attr.diff mhuewe, 2010-08-19 09:11 reset retried attribute on success
Messages (7)
msg114336 - (view) Author: Marcus Huewe (mhuewe) Date: 2010-08-19 09:11
It seems that commit r81636 broke urllib2's AbstractBasicAuthHandler because the "retried" attribute isn't reset on success. Therefore it's limited to 6 requests. The attached patch should fix this problem.
msg114339 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-08-19 10:48
The patch is fine.
msg114381 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-08-19 17:32
Fixed in r84207(release27-maint).
msg114387 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-08-19 18:00
Fixed in py3k (r84210) and release31-maint(r84211). I discovered a new problem while fixing this. It will be taken care in issue9643.
msg122893 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-11-30 08:41
Grr.  Why wasn't this fix backported to the release maintenance branch before 2.6.6 was released?  I've just had an application break as a result of upgrading from 2.6.5 to 2.6.6.

Oh well, too late now. :-(

msg122894 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-11-30 09:09
Ouch. My mistake. Had not realize then, that code that actually broke things was merged in 2.6.x and it had to be fixed too. :(
msg122895 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-11-30 09:17
Ah well, it turned out to be fairly easy to work around, at least. :-)

Just in case any other urllib2 users have to deal with this in 2.6.6 (and also manage to find their way to this bug report :-):  it's easy to monkeypatch your way around the problem.  E.g.:

import sys
import urllib2

if sys.version_info[:2] == (2, 6) and sys.version_info[2] >= 6:
    def fixed_http_error_401(self, req, fp, code, msg, headers):
        url = req.get_full_url()
        response = self.http_error_auth_reqed('www-authenticate',
                                          url, req, headers)
        self.retried = 0
        return response

    urllib2.HTTPBasicAuthHandler.http_error_401 = fixed_http_error_401
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53848
2010-11-30 09:17:17mark.dickinsonsetmessages: + msg122895
2010-11-30 09:09:37orsenthilsetmessages: + msg122894
2010-11-30 08:41:40mark.dickinsonsetnosy: + mark.dickinson
messages: + msg122893
2010-08-19 18:00:44orsenthilsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg114387

stage: resolved
2010-08-19 17:32:33orsenthilsetmessages: + msg114381
2010-08-19 10:48:25orsenthilsetnosy: + orsenthil
messages: + msg114339

assignee: orsenthil
resolution: accepted
2010-08-19 09:11:48mhuewecreate