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

AttributeError from HTTPError when using digest auth #59906

Closed
scjody mannequin opened this issue Aug 16, 2012 · 8 comments
Closed

AttributeError from HTTPError when using digest auth #59906

scjody mannequin opened this issue Aug 16, 2012 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@scjody
Copy link
Mannequin

scjody mannequin commented Aug 16, 2012

BPO 15701
Nosy @orsenthil, @berkerpeksag
Files
  • reproducer.py: reproducer
  • issue15701.diff
  • Issue1571.patch
  • 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 2012-12-23.17:14:40.299>
    created_at = <Date 2012-08-16.20:35:57.181>
    labels = ['library', 'type-crash']
    title = 'AttributeError from HTTPError when using digest auth'
    updated_at = <Date 2014-03-13.16:01:10.256>
    user = 'https://bugs.python.org/scjody'

    bugs.python.org fields:

    activity = <Date 2014-03-13.16:01:10.256>
    actor = 'python-dev'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2012-12-23.17:14:40.299>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2012-08-16.20:35:57.181>
    creator = 'scjody'
    dependencies = []
    files = ['26864', '28238', '28273']
    hgrepos = []
    issue_num = 15701
    keywords = ['patch']
    message_count = 8.0
    messages = ['168407', '169511', '169560', '177270', '177271', '177998', '177999', '213410']
    nosy_count = 4.0
    nosy_names = ['orsenthil', 'python-dev', 'berker.peksag', 'scjody']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue15701'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @scjody
    Copy link
    Mannequin Author

    scjody mannequin commented Aug 16, 2012

    I attempted to connect to a site using urllib2 and digest authentication and it raised an HTTPError (due to an incorrect username and password, which is expected). I attempted to run the info() method of the HTTPError to get more information, but it failed with an AttributeError (this is the bug).

    $ ./reproducer.py 
    Traceback (most recent call last):
      File "./reproducer.py", line 16, in <module>
        print e.info()
      File "/usr/lib/python2.6/urllib.py", line 987, in info
        return self.headers
    AttributeError: 'HTTPError' object has no attribute 'headers'
    $ python --version
    Python 2.6.6

    @scjody scjody mannequin added the type-crash A hard crash of the interpreter, possibly with a core dump label Aug 16, 2012
    @berkerpeksag
    Copy link
    Member

    Python 2.6 is now in security-fix-only mode.

    @berkerpeksag berkerpeksag added the stdlib Python modules in the Lib dir label Aug 31, 2012
    @orsenthil
    Copy link
    Member

    Okay, this is funny. first info is invoking addinfourl of urllib, which would return headers. But in urllib2, the headers are self.hdrs

    I would side with the documentation that info is advertised method for HTTPError object. In 2.7, I guess just docs could be improved. This problem would be the present in 3.x.

    @orsenthil orsenthil self-assigned this Aug 31, 2012
    @orsenthil
    Copy link
    Member

    Even though 2.x is in security fix mode, this can be fixed by a overriding the base class's info method in the HTTPError class and returning the .hdrs attribute instead of .headers.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 10, 2012

    New changeset ad1c1164f68b by Senthil Kumaran in branch 'default':
    Fix bpo-15701 : add .headers attribute to urllib.error.HTTPError
    http://hg.python.org/cpython/rev/ad1c1164f68b

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 23, 2012

    New changeset 3046bfea59f3 by Senthil Kumaran in branch '2.7':
    Fix bpo-15701 - HTTPError info method call raises AttributeError. Fix that to return headers correctly
    http://hg.python.org/cpython/rev/3046bfea59f3

    New changeset 919ebf74bfdb by Senthil Kumaran in branch '3.2':
    Fix bpo-15701 - HTTPError info method call raises AttributeError. Fix that to return headers correctly
    http://hg.python.org/cpython/rev/919ebf74bfdb

    New changeset a15109398294 by Senthil Kumaran in branch '3.3':
    merge from 3.2
    http://hg.python.org/cpython/rev/a15109398294

    @orsenthil
    Copy link
    Member

    Okay. this is fixed in all versions of python. Sorry for the delay.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 13, 2014

    New changeset 361c10d06b9c by R David Murray in branch 'default':
    whatsnew: HTTPError.headers (bpo-15701).
    http://hg.python.org/cpython/rev/361c10d06b9c

    @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-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants