summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2022-09-20 18:42:06 (GMT)
committerGitHub <noreply@github.com>2022-09-20 18:42:06 (GMT)
commit21b5af9072a43275d52737a68d5cda2fab47f730 (patch)
tree55601d70205b93c11f43a85b078276fa41f5a552 /Lib
parent96739bccf220689a54ef33341f431eda19c287fa (diff)
downloadcpython-21b5af9072a43275d52737a68d5cda2fab47f730.zip
cpython-21b5af9072a43275d52737a68d5cda2fab47f730.tar.gz
cpython-21b5af9072a43275d52737a68d5cda2fab47f730.tar.bz2
[3.10] GH-96864: Check for error between line and opcode events (GH-96969)
(cherry picked from commit c10e33ac119d96c4d88d5ae8b59e65a76ae0ad3c)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sys_settrace.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 1f509ee..312b909 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1310,6 +1310,20 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
finally:
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
# moves the execution position - it's how debuggers implement a Jump