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

HTTPError interface changes / breaks depending on what was passed to constructor #57776

Open
Keto mannequin opened this issue Dec 9, 2011 · 2 comments
Open

HTTPError interface changes / breaks depending on what was passed to constructor #57776

Keto mannequin opened this issue Dec 9, 2011 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Keto
Copy link
Mannequin

Keto mannequin commented Dec 9, 2011

BPO 13567
Nosy @ezio-melotti, @merwok, @berkerpeksag, @demianbrecht
Files
  • httperror-geturl-fix-2.patch: HTTPError patch for 2.7
  • httperror-geturl-fix-3.patch: HTTPError patch for 3.3
  • 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 = None
    closed_at = None
    created_at = <Date 2011-12-09.15:54:42.132>
    labels = ['type-bug', 'library']
    title = 'HTTPError interface changes / breaks depending on what was passed to constructor'
    updated_at = <Date 2015-04-26.16:41:44.398>
    user = 'https://bugs.python.org/Keto'

    bugs.python.org fields:

    activity = <Date 2015-04-26.16:41:44.398>
    actor = 'demian.brecht'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2011-12-09.15:54:42.132>
    creator = 'Keto'
    dependencies = []
    files = ['23892', '23893']
    hgrepos = []
    issue_num = 13567
    keywords = ['patch']
    message_count = 2.0
    messages = ['149106', '149107']
    nosy_count = 5.0
    nosy_names = ['ezio.melotti', 'eric.araujo', 'berker.peksag', 'Keto', 'demian.brecht']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue13567'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @Keto
    Copy link
    Mannequin Author

    Keto mannequin commented Dec 9, 2011

    In case of authentication error, HTTPError gets initialized without file object and constructor of addinfourl is not called. This means that url attribute is not set and geturl() (inherited from addinfourl) raises AttributeError.

    geturl() is not documented as part of HTTPError interface, so I'm not sure if it is correct to expect it to work. And of course this can be worked around by using the HTTPError.filename which always contains the url passed to constructor.

    How ever, I have made a simple patch to fix the missing attribute.

    There is also bpo-5286 with a patch, which makes the http_error_auth_reqed pass the fp to HTTPError making it a file-like object as stated in the documentation. So that would probably be the correct solution.

    IMHO it's a bit bad design, when objects interface changes depending on how it was initialized.

    @Keto Keto mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 9, 2011
    @Keto
    Copy link
    Mannequin Author

    Keto mannequin commented Dec 9, 2011

    Patch adapted to 3.3

    @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

    0 participants