summaryrefslogtreecommitdiff
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-01-02 11:38:44 +0000
committerGitHub <noreply@github.com>2020-01-02 11:38:44 +0000
commit04ec7a1f7a5b92187a73cd02670958444c6f2220 (patch)
treedf7e34cd5c5ef3e80ce51ab6c6ad85dba37de8e0 /Python/ceval.c
parent149175c6dfc8455023e4335575f3fe3d606729f9 (diff)
downloadcpython-git-04ec7a1f7a5b92187a73cd02670958444c6f2220.tar.gz
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 96ed329b0d..bd9454b281 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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;
}