-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
STOP_ITERATION
monitoring event is not triggered by unspecialized bytecode
#116090
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
It should be easy to remove the opcode fusion from |
For @markshannon. |
FTR, this is expected behavior. You either get a The reason for this slightly odd behavior is as follows:
|
That would result in both the |
In hindsight, we should probably tried to have done the following:
Maybe we could do this for 3.14 |
…hausting a generator. (GH-120697)
…thonGH-122413). (cherry picked from commit 15d4cd0) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
…thonGH-122413). (cherry picked from commit 15d4cd0) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
The current behavior might be a bit more complicated than it could be, but it works and any changes risk breaking backwards compatibility. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
Repro: Check out this commit, build, and run
python -mtest test_monitoring -mtest_implicit_stop_iteration
.Context: The unspecialized implementation of
FOR_ITER
has some built-in opcode fusion, in that it skips the followingEND_FOR
andPOP_TOP
whentp_iternext
returnsNULL
. When the iterator is a generator, as it is inExceptionMonitoringTest.test_implicit_stop_iteration()
, that means we skip themonitor_stop_iteration()
call inINSTRUMENTED_END_FOR
.test_implicit_stop_iteration()
passes as written, though, because theFOR_ITER
in the helper function has been specialized toFOR_ITER_GEN
by the time the generator finishes, andFOR_ITER_GEN
's implementation doesn't perform the same fusion asFOR_ITER
.This bug can be exposed by making this change to
test_implicit_stop_iteration()
, so theFOR_ITER
stays unspecialized while iterating over the generator in question.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
RAISE
events from_FOR_ITER_TIER_TWO
#122413RAISE
events from_FOR_ITER_TIER_TWO
(GH-122413) #122419The text was updated successfully, but these errors were encountered: