mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
GH-96864: Check for error between line and opcode events (GH-96880)
(cherry picked from commit c10e33ac11
)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
This commit is contained in:
parent
fc1cbe761b
commit
32d80decbf
3 changed files with 17 additions and 1 deletions
|
@ -1721,6 +1721,20 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
|
||||||
finally:
|
finally:
|
||||||
sys.settrace(existing)
|
sys.settrace(existing)
|
||||||
|
|
||||||
|
def test_line_event_raises_before_opcode_event(self):
|
||||||
|
exception = ValueError("BOOM!")
|
||||||
|
def trace(frame, event, arg):
|
||||||
|
if event == "line":
|
||||||
|
raise exception
|
||||||
|
frame.f_trace_opcodes = True
|
||||||
|
return trace
|
||||||
|
def f():
|
||||||
|
pass
|
||||||
|
with self.assertRaises(ValueError) as caught:
|
||||||
|
sys.settrace(trace)
|
||||||
|
f()
|
||||||
|
self.assertIs(caught.exception, exception)
|
||||||
|
|
||||||
|
|
||||||
# 'Jump' tests: assigning to frame.f_lineno within a trace function
|
# 'Jump' tests: assigning to frame.f_lineno within a trace function
|
||||||
# moves the execution position - it's how debuggers implement a Jump
|
# moves the execution position - it's how debuggers implement a Jump
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a possible assertion failure, fatal error, or :exc:`SystemError` if a
|
||||||
|
line tracing event raises an exception while opcode tracing is enabled.
|
|
@ -6933,7 +6933,7 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Always emit an opcode event if we're tracing all opcodes. */
|
/* Always emit an opcode event if we're tracing all opcodes. */
|
||||||
if (f->f_trace_opcodes) {
|
if (f->f_trace_opcodes && result == 0) {
|
||||||
result = call_trace(func, obj, tstate, frame, PyTrace_OPCODE, Py_None);
|
result = call_trace(func, obj, tstate, frame, PyTrace_OPCODE, Py_None);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue