-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
STOP_ITERATION monitoring event is not triggered by unspecialized bytecode
#116090
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>

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

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_ITERhas some built-in opcode fusion, in that it skips the followingEND_FORandPOP_TOPwhentp_iternextreturnsNULL. 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_ITERin the helper function has been specialized toFOR_ITER_GENby 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_ITERstays unspecialized while iterating over the generator in question.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
RAISEevents from_FOR_ITER_TIER_TWO#122413RAISEevents from_FOR_ITER_TIER_TWO(GH-122413) #122419The text was updated successfully, but these errors were encountered: