Repository navigation
GH-90997: Wrap yield from/await in a virtual try/except StopIteration
#96010
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
Changes from 9 commits
c05c2af
819e0df
d557e41
d5e033a
b4f26d8
0cb78f2
4b0e60f
a0953b1
afdf25e
5348cbe
f4cc398
f085a2e
296bc08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,7 +166,7 @@ def bug1333982(x=[]): | |
| dis_bug1333982 = """\ | ||
| %3d RESUME 0 | ||
|
|
||
| %3d LOAD_ASSERTION_ERROR | ||
| %3d LOAD_EXCEPTION_TYPE 0 (AssertionError) | ||
| LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>) | ||
| MAKE_FUNCTION 0 | ||
| LOAD_FAST 0 (x) | ||
|
|
@@ -507,26 +507,52 @@ async def _asyncwith(c): | |
| LOAD_CONST 0 (None) | ||
| RETURN_VALUE | ||
|
|
||
| %3d >> PUSH_EXC_INFO | ||
| %3d >> LOAD_EXCEPTION_TYPE 1 (StopIteration) | ||
| CHECK_EXC_MATCH | ||
| POP_JUMP_FORWARD_IF_TRUE 1 (to 74) | ||
| RERAISE 0 | ||
| >> LOAD_ATTR 0 (value) | ||
| SWAP 3 | ||
| POP_TOP | ||
| POP_TOP | ||
| JUMP_BACKWARD 40 (to 22) | ||
| >> LOAD_EXCEPTION_TYPE 1 (StopIteration) | ||
| CHECK_EXC_MATCH | ||
| POP_JUMP_FORWARD_IF_TRUE 1 (to 110) | ||
| RERAISE 0 | ||
| >> LOAD_ATTR 0 (value) | ||
| SWAP 3 | ||
| POP_TOP | ||
| POP_TOP | ||
| JUMP_BACKWARD 41 (to 56) | ||
| >> PUSH_EXC_INFO | ||
| WITH_EXCEPT_START | ||
| GET_AWAITABLE 2 | ||
| LOAD_CONST 0 (None) | ||
| >> SEND 3 (to 82) | ||
| >> SEND 20 (to 188) | ||
| YIELD_VALUE 6 | ||
| RESUME 3 | ||
| JUMP_BACKWARD_NO_INTERRUPT 4 (to 74) | ||
| >> POP_JUMP_FORWARD_IF_TRUE 1 (to 86) | ||
| JUMP_BACKWARD_NO_INTERRUPT 4 (to 146) | ||
| >> LOAD_EXCEPTION_TYPE 1 (StopIteration) | ||
| CHECK_EXC_MATCH | ||
| POP_JUMP_FORWARD_IF_TRUE 1 (to 162) | ||
| RERAISE 0 | ||
| >> LOAD_ATTR 0 (value) | ||
| SWAP 3 | ||
| POP_TOP | ||
| POP_TOP | ||
| >> POP_JUMP_FORWARD_IF_TRUE 1 (to 192) | ||
| RERAISE 2 | ||
| >> POP_TOP | ||
| POP_EXCEPT | ||
| POP_TOP | ||
| POP_TOP | ||
| JUMP_BACKWARD 19 (to 58) | ||
| JUMP_BACKWARD 72 (to 58) | ||
| >> COPY 3 | ||
| POP_EXCEPT | ||
| RERAISE 1 | ||
| ExceptionTable: | ||
| 2 rows | ||
| 6 rows | ||
| """ % (_asyncwith.__code__.co_firstlineno, | ||
| _asyncwith.__code__.co_firstlineno + 1, | ||
| _asyncwith.__code__.co_firstlineno + 2, | ||
|
|
@@ -1350,8 +1376,9 @@ async def async_def(): | |
| 0: None | ||
| 1: 1 | ||
| Names: | ||
| 0: b | ||
| 1: c | ||
| 0: value | ||
| 1: b | ||
| 2: c | ||
| Variable names: | ||
| 0: a | ||
| 1: d""" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to also add a test that shows what you're fixing here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, we're not really fixing anything (in fact, we want the behavior to stay exactly the same). All we're really doing is moving some of the error handling logic for I'm confident that the tests in |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Compile virtual :keyword:`try`/:keyword:`except` blocks to handle exceptions | ||
| raised during :meth:`~generator.close` or :meth:`~generator.throw` calls | ||
| through a suspended frame. |
Uh oh!
There was an error while loading. Please reload this page.