Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Bug report
Bug description:
Repro: Check outthis commit, build, and runpython -mtest test_monitoring -mtest_implicit_stop_iteration.
Context: The unspecialized implementation ofFOR_ITER has some built-in opcode fusion, in thatit 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 makingthis change totest_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