-
-
Notifications
You must be signed in to change notification settings - Fork 28
Submission for SC consideration: PEP 678 -- Enriching Exceptions with Notes #105
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
Comments
Thanks! I've added it to the agenda. |
Hi @encukou - following additional discussion in the discuss.python.org thread since I opened this issue, we are planning some minor changes. (storing a sequence of strings rather than a string-or-None incurs a little extra complexity, but makes translation use-cases much easier to support). Up to you whether that should affect the agenda. |
@Zac-HD We will leave it on the agenda but skip over it until you're ready again for us to have a look. |
We've settled on an updated design with |
The PEP is back/still in our agenda. |
One thing I noticed about the PEP is it doesn't actually say what I would also suggest tweaking the title of the section https://www.python.org/dev/peps/pep-0678/#store-notes-in-exceptiongroups to say "Store notes in ExceptionGroups only". Otherwise if you didn't know that |
Per python/cpython#31317, it appends to an internal list, we create a new tuple each time - mutating in place seems unsafe when the user might have gotten a reference to the tuple already! I'll update the text to clarify this, and change the title of that section to "Store notes in |
I totally agree, hence wanting the clarification. 😁 |
Irit and I talked this over; the PEP is now clear that the tuple is replaced each time a note is added (so you get the same object on every access between updates), and the implementing PR has been updated accordingly. |
Why would it matter if a tuple of strings is the same object each time? That's a pure value. (Yes, sure, perf, but that's a quality of implementation issue, shouldn't have to be specified in the PEP. This isn't going to hit O(N^2) territory. |
I don't think it matters or needs to be specified, but since Brett asked above I wrote it in. Happy to take that back out if SC agrees. |
My concern is someone is going to store that tuple somewhere thinking it isn't going to change at the moment that they saw it, and then whoops, it does, since tuples are generally viewed as immutable. |
Of course the tuple would be immutable. |
Then I don't understand your concern. The PEP didn't specify what |
This was the actual change in the pep (https://github.com/python/peps/pull/2377/files). Do you think it’s over specifying how notes is updated? |
I put my answer in python/peps#2377 (comment) |
Ping us when the PEP text is updated to reflect the simpler version per the current discussions. https://discuss.python.org/t/pep-678-enriching-exceptions-with-notes/13374/74?u=gpshead |
The PEP text has been updated in python/peps#2456. The key changes are to make |
Uh oh!
There was an error while loading. Please reload this page.
Please consider PEP 678, https://www.python.org/dev/peps/pep-0678/
This proposal arose out discussions about use of
ExceptionGroup
, as a way to attach extra information when exception chaining is undesirable (e.g. because a library does not wish to change the exception type). The motivation section discusses use by testing libraries such as Hypothesis and Pytest, with concurrency like Trio or with serial retries, and in teaching environments such as friendly-traceback.The text was updated successfully, but these errors were encountered: