summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-09-07 17:23:11 (GMT)
committerGitHub <noreply@github.com>2023-09-07 17:23:11 (GMT)
commit96396962ce7a83c09bac5061121c779ca6b25ef5 (patch)
treebc1d4bbd691a159bf5255a886e4dacbba8821c14 /Lib
parent403ab1306a6e9860197bce57eadcb83418966f21 (diff)
downloadcpython-96396962ce7a83c09bac5061121c779ca6b25ef5.zip
cpython-96396962ce7a83c09bac5061121c779ca6b25ef5.tar.gz
cpython-96396962ce7a83c09bac5061121c779ca6b25ef5.tar.bz2
gh-109094: remove unnecessary updates of frame->prev_instr in instrumentation functions (#109076)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sys_settrace.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 2329008..369a276 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -317,6 +317,13 @@ generator_example.events = ([(0, 'call'),
[(5, 'line'), (5, 'return')])
+def lineno_matches_lasti(frame):
+ last_line = None
+ for start, end, line in frame.f_code.co_lines():
+ if start <= frame.f_lasti < end:
+ last_line = line
+ return last_line == frame.f_lineno
+
class Tracer:
def __init__(self, trace_line_events=None, trace_opcode_events=None):
self.trace_line_events = trace_line_events
@@ -330,6 +337,7 @@ class Tracer:
frame.f_trace_opcodes = self.trace_opcode_events
def trace(self, frame, event, arg):
+ assert lineno_matches_lasti(frame)
self._reconfigure_frame(frame)
self.events.append((frame.f_lineno, event))
return self.trace
@@ -1890,6 +1898,7 @@ class JumpTracer:
def trace(self, frame, event, arg):
if self.done:
return
+ assert lineno_matches_lasti(frame)
# frame.f_code.co_firstlineno is the first line of the decorator when
# 'function' is decorated and the decorator may be written using
# multiple physical lines when it is too long. Use the first line