Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib2's AbstractBasicAuthHandler is limited to 6 requests #53848

Closed
mhuewe mannequin opened this issue Aug 19, 2010 · 7 comments
Closed

urllib2's AbstractBasicAuthHandler is limited to 6 requests #53848

mhuewe mannequin opened this issue Aug 19, 2010 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mhuewe
Copy link
Mannequin

mhuewe mannequin commented Aug 19, 2010

BPO 9639
Nosy @mdickinson, @orsenthil
Files
  • urllib2-AbstractBasicAuthHandler_reset_attr.diff: reset retried attribute on success
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/orsenthil'
    closed_at = <Date 2010-08-19.18:00:44.509>
    created_at = <Date 2010-08-19.09:11:48.085>
    labels = ['type-bug', 'library']
    title = "urllib2's AbstractBasicAuthHandler is limited to 6 requests"
    updated_at = <Date 2010-11-30.09:17:17.929>
    user = 'https://bugs.python.org/mhuewe'

    bugs.python.org fields:

    activity = <Date 2010-11-30.09:17:17.929>
    actor = 'mark.dickinson'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2010-08-19.18:00:44.509>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2010-08-19.09:11:48.085>
    creator = 'mhuewe'
    dependencies = []
    files = ['18574']
    hgrepos = []
    issue_num = 9639
    keywords = ['patch']
    message_count = 7.0
    messages = ['114336', '114339', '114381', '114387', '122893', '122894', '122895']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'orsenthil', 'mhuewe']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9639'
    versions = ['Python 2.7']

    @mhuewe
    Copy link
    Mannequin Author

    mhuewe mannequin commented Aug 19, 2010

    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.

    @mhuewe mhuewe mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 19, 2010
    @orsenthil
    Copy link
    Member

    The patch is fine.

    @orsenthil orsenthil self-assigned this Aug 19, 2010
    @orsenthil
    Copy link
    Member

    Fixed in r84207(release27-maint).

    @orsenthil
    Copy link
    Member

    Fixed in py3k (r84210) and release31-maint(r84211). I discovered a new problem while fixing this. It will be taken care in bpo-9643.

    @mdickinson
    Copy link
    Member

    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. :-(

    </grumble>

    @orsenthil
    Copy link
    Member

    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. :(

    @mdickinson
    Copy link
    Member

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants