Skip to content

Commit 05f1a8e

Browse files
committed
Fix trampoline raise panic and unxfail passing traces
Do not decode inline-cache units as opcodes when a flattened call raises. Remove expectedFailure from test_trace and test_regrtest coverage tests that now pass. Assisted-by: Grok:grok-4.6
1 parent 1828c71 commit 05f1a8e

3 files changed

Lines changed: 3 additions & 18 deletions

File tree

‎Lib/test/test_regrtest.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,6 @@ def test_slowest_interrupted(self):
12261226
regex = ('10 slowest tests:\n')
12271227
self.check_line(output, regex)
12281228

1229-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Regex didn't match: '^lines +cov% +module +\\(path\\)\\n(?: *[0-9]+ *[0-9]{1,2}\\.[0-9]% *[^ ]+ +\\([^)]+\\)+)+' not found in 'Warning: collecting coverage without -j is imprecise. Configure --with-pydebug and run -m test -T -j for best results.\nUsing random seed: 2780369491\n0:00:00 Run 1 test sequentially in a single process\n0:00:00 [1/1] test_regrtest_coverage\n0:00:00 [1/1] test_regrtest_coverage passed\n\n== Tests result: SUCCESS ==\n\n1 test OK.\n\nTotal duration: 102 ms\nTotal tests: run=1\nTotal test files: run=1/1\nResult: SUCCESS\n'
12301229
def test_coverage(self):
12311230
# test --coverage
12321231
test = self.create_test('coverage')

‎Lib/test/test_trace.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def setUp(self):
130130
self.tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
131131
self.my_py_filename = fix_ext_py(__file__)
132132

133-
@unittest.expectedFailure # TODO: RUSTPYTHON; + ('crates/pylib/Lib/test/test_trace.py', 48): 1}
134133
def test_traced_func_linear(self):
135134
result = self.tracer.runfunc(traced_func_linear, 2, 5)
136135
self.assertEqual(result, 7)
@@ -143,7 +142,6 @@ def test_traced_func_linear(self):
143142

144143
self.assertEqual(self.tracer.results().counts, expected)
145144

146-
@unittest.expectedFailure # TODO: RUSTPYTHON; + ('crates/pylib/Lib/test/test_trace.py', 54): 1}
147145
def test_traced_func_loop(self):
148146
self.tracer.runfunc(traced_func_loop, 2, 3)
149147

@@ -156,7 +154,6 @@ def test_traced_func_loop(self):
156154
}
157155
self.assertEqual(self.tracer.results().counts, expected)
158156

159-
@unittest.expectedFailure # TODO: RUSTPYTHON; + ('crates/pylib/Lib/test/tracedmodules/testmod.py', 3): 1}
160157
def test_traced_func_importing(self):
161158
self.tracer.runfunc(traced_func_importing, 2, 5)
162159

@@ -169,7 +166,6 @@ def test_traced_func_importing(self):
169166

170167
self.assertEqual(self.tracer.results().counts, expected)
171168

172-
@unittest.expectedFailure # TODO: RUSTPYTHON; + ('crates/pylib/Lib/test/test_trace.py', 76): 10}
173169
def test_trace_func_generator(self):
174170
self.tracer.runfunc(traced_func_calling_generator)
175171

@@ -185,7 +181,6 @@ def test_trace_func_generator(self):
185181
}
186182
self.assertEqual(self.tracer.results().counts, expected)
187183

188-
@unittest.expectedFailure # TODO: RUSTPYTHON; + ('crates/pylib/Lib/test/test_trace.py', 87): 1}
189184
def test_trace_list_comprehension(self):
190185
self.tracer.runfunc(traced_caller_list_comprehension)
191186

@@ -199,7 +194,6 @@ def test_trace_list_comprehension(self):
199194
}
200195
self.assertEqual(self.tracer.results().counts, expected)
201196

202-
@unittest.expectedFailure # TODO: RUSTPYTHON; Diff is 996 characters long. Set self.maxDiff to None to see it.
203197
def test_traced_decorated_function(self):
204198
self.tracer.runfunc(traced_decorated_function)
205199

@@ -219,7 +213,6 @@ def test_traced_decorated_function(self):
219213
}
220214
self.assertEqual(self.tracer.results().counts, expected)
221215

222-
@unittest.expectedFailure # TODO: RUSTPYTHON; + {('crates/pylib/Lib/test/test_trace.py', 108): 1}
223216
def test_linear_methods(self):
224217
# XXX todo: later add 'static_method_linear' and 'class_method_linear'
225218
# here, once issue1764286 is resolved
@@ -243,7 +236,6 @@ def setUp(self):
243236
self.my_py_filename = fix_ext_py(__file__)
244237
self.addCleanup(sys.settrace, sys.gettrace())
245238

246-
@unittest.expectedFailure # TODO: RUSTPYTHON; KeyError: ('crates/pylib/Lib/test/test_trace.py', 51)
247239
def test_exec_counts(self):
248240
self.tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
249241
code = r'''traced_func_loop(2, 5)'''
@@ -545,7 +537,6 @@ def test_sys_argv_list(self):
545537
PYTHONIOENCODING='utf-8')
546538
self.assertIn(direct_stdout.strip(), trace_stdout)
547539

548-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'lines cov% module (path)' not found in ''
549540
def test_count_and_summary(self):
550541
filename = f'{TESTFN}.py'
551542
coverfilename = f'{TESTFN}.cover'
@@ -581,7 +572,6 @@ def setUp(self):
581572
self.tracer = Trace(count=0, trace=1)
582573
self.filemod = my_file_and_modname()
583574

584-
@unittest.expectedFailure # TODO: RUSTPYTHON; IndexError: list index out of range
585575
def test_no_source_file(self):
586576
filename = "<unknown>"
587577
co = traced_func_linear.__code__

‎crates/vm/src/frame.rs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,13 +2661,9 @@ pub(crate) fn trampoline_handle_exception(
26612661
) -> FrameResult {
26622662
let mut exec = exec_iframe(iframe, Flatten::Nothing, vm);
26632663

2664-
// lasti points past the call opcode and its inline caches. Walk back
2665-
// over CACHE units so traceback / raise events use the call itself.
2666-
let mut idx = (exec.lasti() as usize).saturating_sub(1);
2667-
while idx > 0 && matches!(exec.code.instructions.read_op(idx), Instruction::Cache) {
2668-
idx -= 1;
2669-
}
2670-
exec.update_lasti(|i| *i = idx as u32 + 1);
2664+
// lasti points past the call opcode and its inline caches. Do not
2665+
// decode those cache units: their bytes are not valid opcodes.
2666+
let idx = (exec.lasti() as usize).saturating_sub(1);
26712667

26722668
// Add traceback entry at the call site.
26732669
if let Some((loc, _end_loc)) = exec.code.locations.get(idx) {

0 commit comments

Comments
 (0)