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 doesn't have a good "repr" representation #68075

Closed
facundobatista opened this issue Apr 8, 2015 · 6 comments
Closed

HTTPError doesn't have a good "repr" representation #68075

facundobatista opened this issue Apr 8, 2015 · 6 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@facundobatista
Copy link
Member

BPO 23887
Nosy @facundobatista, @berkerpeksag, @vadmium, @demianbrecht
Files
  • issue23887.diff
  • 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 = <Date 2015-04-22.21:49:10.750>
    created_at = <Date 2015-04-08.11:44:13.890>
    labels = ['type-feature', 'library']
    title = 'HTTPError doesn\'t have a good "repr" representation'
    updated_at = <Date 2015-04-23.03:19:50.687>
    user = 'https://github.com/facundobatista'

    bugs.python.org fields:

    activity = <Date 2015-04-23.03:19:50.687>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-04-22.21:49:10.750>
    closer = 'facundobatista'
    components = ['Library (Lib)']
    creation = <Date 2015-04-08.11:44:13.890>
    creator = 'facundobatista'
    dependencies = []
    files = ['38863']
    hgrepos = []
    issue_num = 23887
    keywords = ['patch']
    message_count = 6.0
    messages = ['240262', '240263', '240269', '240462', '241257', '241828']
    nosy_count = 5.0
    nosy_names = ['facundobatista', 'python-dev', 'berker.peksag', 'martin.panter', 'demian.brecht']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23887'
    versions = ['Python 3.5']

    @facundobatista
    Copy link
    Member Author

    I normally print(repr()) the exception I got, for debugging purposes. I use repr() because for builtin exceptions, str() will print only the message, and not the exception type.

    But for HTTPError, the repr() of it is "HTTPError()", without further explanation...

    @berkerpeksag
    Copy link
    Member

    HTTPError.str already provides useful information: 'HTTP Error %s: %s' % (self.code, self.msg), but since the change is minimal and useful, here is a patch.

    @berkerpeksag berkerpeksag added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Apr 8, 2015
    @demianbrecht
    Copy link
    Mannequin

    demianbrecht mannequin commented Apr 8, 2015

    A test really should be added for this. Otherwise, LGTM.

    @vadmium
    Copy link
    Member

    vadmium commented Apr 11, 2015

    Perhaps it would be more appropriate to set the BaseException.args attribute, or chain to its __init__() method, then you wouldn’t need a custom __repr__().

    @facundobatista
    Copy link
    Member Author

    Hi Berker, I like your patch, will apply it after doing a test for it.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 22, 2015

    New changeset e9ea679a92fa by Facundo Batista in branch 'default':
    Issue bpo-23887: urllib.error.HTTPError now has a proper repr() representation.
    https://hg.python.org/cpython/rev/e9ea679a92fa

    @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-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants