You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an optimization in gen_close which attempts to shortcut the case where a sub-generator is being closed, and it is wrapped in only one try block (which is presumed to be for the StopIteration so can be ignored).
However, there is a bug there where the exception depth is taken from frame->prev_instr[0].op.code, where it should be frame->prev_instr[0].op.arg.
At the moment this optimization is not doing anything because exception_handler_depth is never 1, it is either 118 (opcode of YIELD_VALUE) or 241 (opcode of INSTRUMENTED_YIELD_VALUE). If one of those opcodes will happen to be mapped to 1, then this code will have some impact but obviously not the intended one.
Activity
iritkatriel commentedon Oct 20, 2023
If I try to fix the typo and use
op.arginstead ofop.code, some tests fail: #111069I think the return value is incorrect in some cases.
iritkatriel commentedon Oct 20, 2023
The failure in testcontextlib is fixed by setting the frame state in case we return early:
Eclips4 commentedon Oct 20, 2023
Probably related: #111058
iritkatriel commentedon Oct 23, 2023
Perf measurement for #111069:
https://github.com/faster-cpython/benchmarking/blob/main/results/bm-20231020-3.13.0a1%2B-90d6409/bm-20231020-linux-x86_64-iritkatriel-refleak-3.13.0a1%2B-90d6409-vs-base.md