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

Use raise from when raising new IncompleteRead #73139

Closed
cool-RR mannequin opened this issue Dec 12, 2016 · 8 comments
Closed

Use raise from when raising new IncompleteRead #73139

cool-RR mannequin opened this issue Dec 12, 2016 · 8 comments
Labels
3.11 only security fixes easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@cool-RR
Copy link
Mannequin

cool-RR mannequin commented Dec 12, 2016

BPO 28953
Nosy @cool-RR, @miss-islington, @iritkatriel, @180909
PRs
  • bpo-28953: Use raise from when raising new IncompleteRead #29861
  • Files
  • 1.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 = None
    closed_at = <Date 2021-12-07.00:13:07.606>
    created_at = <Date 2016-12-12.21:43:13.919>
    labels = ['easy', 'type-bug', 'library', '3.11']
    title = 'Use `raise from` when raising new IncompleteRead'
    updated_at = <Date 2021-12-07.00:13:07.606>
    user = 'https://github.com/cool-RR'

    bugs.python.org fields:

    activity = <Date 2021-12-07.00:13:07.606>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-07.00:13:07.606>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2016-12-12.21:43:13.919>
    creator = 'cool-RR'
    dependencies = []
    files = ['45865']
    hgrepos = []
    issue_num = 28953
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['283052', '407608', '407645', '407651', '407655', '407657', '407659', '407882']
    nosy_count = 4.0
    nosy_names = ['cool-RR', 'miss-islington', 'iritkatriel', 'wangjiahua']
    pr_nums = ['29861']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue28953'
    versions = ['Python 3.11']

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 12, 2016

    I had this error come up in my code, and because it doesn't use raise ... from I thought that the second error was unexpected, while in fact it wasn't. This patch should fix that.

    @cool-RR cool-RR mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 12, 2016
    @iritkatriel iritkatriel added easy 3.11 only security fixes and removed 3.7 (EOL) end of life labels Jun 22, 2021
    @iritkatriel
    Copy link
    Member

    I just pushed a new feature which may provide a simpler way to do this: https://bugs.python.org/issue45607

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 4, 2021

    Interesting feature Irit, thank you

    Two things:

    1. Is there better documentation for that feature than what was in the CL of the issue you linked to? Because that documentation was more lawyery than explanatory.

    2. If I understand correctly, the note is meant for things that don't exactly fit in the exception message for some reason or another. (A better documentation with examples would have given me a clearer understanding of your use cases.) I'm not sure why the message included here should be relegated to a note.

    @iritkatriel
    Copy link
    Member

    It’s meant for thing you want to add to the msg after the exception was created. The PR here seems to create a new exception of the same type in order to chain it with an additional msg. I’m suggesting that it might be sufficient to attach a note to the existing exception instead.

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 4, 2021

    This might work here, but you'd need to be sure there isn't any important code that looks at the IncompleteRead exception and expects the data to be in its message.

    Also I hope that various tools like IDEs would learn quickly that they need to display the note in their traceback views, otherwise all of these notes would be hidden from many people.

    @iritkatriel
    Copy link
    Member

    Exception message text is not part of the api. The type is.

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 4, 2021

    Okay, works for me.

    @miss-islington
    Copy link
    Contributor

    New changeset c5c3652 by 180909 in branch 'main':
    bpo-28953: Use raise from when raising new IncompleteRead (GH-29861)
    c5c3652

    @asvetlov asvetlov closed this as completed Dec 7, 2021
    @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
    3.11 only security fixes easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants