mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-39114: Fix tracing of except handlers with name binding (GH-17769)
When producing the bytecode of exception handlers with name binding (like `except Exception as e`) we need to produce a try-finally block to make sure that the name is deleted after the handler is executed to prevent cycles in the stack frame objects. The bytecode associated with this try-finally block does not have source lines associated and it was causing problems when the tracing functionality was running over it.
This commit is contained in:
parent
149175c6df
commit
04ec7a1f7a
3 changed files with 50 additions and 1 deletions
|
@ -3610,7 +3610,9 @@ exception_unwind:
|
|||
PUSH(val);
|
||||
PUSH(exc);
|
||||
JUMPTO(handler);
|
||||
if (_Py_TracingPossible(ceval)) {
|
||||
if (_Py_TracingPossible(ceval) &&
|
||||
((f->f_lasti < instr_lb || f->f_lasti >= instr_ub) ||
|
||||
!(f->f_lasti == instr_lb || f->f_lasti < instr_prev))) {
|
||||
/* Make sure that we trace line after exception */
|
||||
instr_prev = INT_MAX;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue