-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
bpo-45292: [PEP-654] add except* #29581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwaway comment. You may want to ask @pablogsal and/or @lysnikolaou for a review of the parser parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments about list/tuple API, refcounts, and test coverage in Objects/exceptions.c
and Python/ceval.c
. I'll save the PEP 7 nitpicks for later ;)
The bug is actually related to the exception table lookup. This test fails at the 1/0:
with:
If I change except* to except it prints:
The except*/except change should not impact the level of the 1/0 instruction. |
@markshannon Can you look at Irit’s last comment? Is it perhaps because the exception table is generated by magic opposes? |
Here is the relevant dis:
Old except:
Except*:
I think it's wrong that an exception from line 90 jumps to line 84. I'm missing something that tells it to go directly to line 100 from there. |
…ssage for mixed except and except*. Add tests for custom errors
@markshannon I think I found the bug - there was a POP_BLOCK that needed to move out of the loop. I'll add a few unit tests and push it. |
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
…* cases in compiler
This reverts commit ca44878.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming Mark and Erlend will handle the remaining review tasks here. I may occasionally take a peek and find something superficial. :-)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
I hope so, but let us know if you are not planning to (@markshannon , @erlend-aasland). @ambv - you also had a close look/experimentation with this PR, any comments from you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic job! Here's an "#*%!( lot of nitpicks; feel free to ignore them 🙂 But, more important: I found some branches that weren't covered by the test suite. If possible, we should increase coverage. I also left some comments regarding usage of some C API's.
Nitpicks come in two flavours:
- PEP 7 nitpicks. (I started applying PEP 7 comments to
Python/compile.c
as well, but I guess it's ok to disregard PEP 7 for that file.) - Minor C API nitpicks (mostly use
Py_Is
,Py_IsNone
, etc.). Do with these comments as you want 🗑️
Thank you Erlend! Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
…l/cpython into bpo-45292-except_star
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge whenever you feel ready!
I don't think that this was ready to merge. As I said before, this does too much in the interpreter that should be done in the compiler. |
Sorry if we jumped the gun. But this works well enough so that we can start writing code that uses it (which is a requirement the SC gave us when they approved PEP 654). I suppose we could do that in a branch, but that's very awkward -- it places a high barrier on those who just want to experiment with what this feels like. There will be plenty of opportunity to refactor the implementation -- we have many alpha releases left until beta 1 (late May), and even after that we can fix bugs until the release candidates start (in August). |
@ambv has been doing it in a branch and did not report any bugs so far. We need more people to start using it, we need feedback on both the semantics and the implementation, and we need to give @1st1 time to develop the asyncio parts. Indeed, I am keen to hear @markshannon's ideas about refactoring/simplifying/optimizing the implementation. The first suggestion (2-3 weeks ago) didn't work because it overlooked that fact that we need to maintain state between the except* clauses. Hopefully we can find something that does work. |
Let's move that discussion back to bpo-45292. |
Unfortunately, this change results in a 1% slowdown |
https://bugs.python.org/issue45292