diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-08 12:40:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 12:40:35 (GMT) |
commit | 23ee4a8067506e6c9c47748185653617413f7a60 (patch) | |
tree | 53fa47cbd1742dd6809e3d1ed31e449b86631c1a /Python | |
parent | e5b841a4037d1c2ce3d12a584facf800ae36332a (diff) | |
download | cpython-23ee4a8067506e6c9c47748185653617413f7a60.zip cpython-23ee4a8067506e6c9c47748185653617413f7a60.tar.gz cpython-23ee4a8067506e6c9c47748185653617413f7a60.tar.bz2 |
gh-94215: Fix error handling for line-tracing events (GH-94681)
* Re-enable crasher
* Fix error handling for line-tracing events
* blurb add
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index cdb14d8..0176002 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5683,16 +5683,25 @@ handle_eval_breaker: err = maybe_call_line_trace(tstate->c_tracefunc, tstate->c_traceobj, tstate, frame, instr_prev); + // Reload possibly changed frame fields: + stack_pointer = _PyFrame_GetStackPointer(frame); + frame->stacktop = -1; + // next_instr is only reloaded if tracing *does not* raise. + // This is consistent with the behavior of older Python + // versions. If a trace function sets a new f_lineno and + // *then* raises, we use the *old* location when searching + // for an exception handler, displaying the traceback, and + // so on: if (err) { - /* trace function raised an exception */ + // next_instr wasn't incremented at the start of this + // instruction. Increment it before handling the error, + // so that it looks the same as a "normal" instruction: next_instr++; goto error; } - /* Reload possibly changed frame fields */ + // Reload next_instr. Don't increment it, though, since + // we're going to re-dispatch to the "true" instruction now: next_instr = frame->prev_instr; - - stack_pointer = _PyFrame_GetStackPointer(frame); - frame->stacktop = -1; } } } |