Skip to content

Commit 0a10e6c

Browse files
authored
Merge pull request RustPython#4963 from matthew-hagemann/fix/silent-if-error-in-trace()
Set trace_func / profile_func to none on error
2 parents 698134c + 935e35b commit 0a10e6c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Lib/test/test_trace.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ def test_simple_caller(self):
298298
}
299299
self.assertEqual(self.tracer.results().calledfuncs, expected)
300300

301-
# TODO: RUSTPYTHON, gc
302-
@unittest.expectedFailure
303301
def test_arg_errors(self):
304302
res = self.tracer.runfunc(traced_capturer, 1, 2, self=3, func=4)
305303
self.assertEqual(res, ((1, 2), {'self': 3, 'func': 4}))
@@ -552,8 +550,6 @@ def test_listfuncs_flag_success(self):
552550
expected = f'filename: {filename}, modulename: {modulename}, funcname: <module>'
553551
self.assertIn(expected.encode(), stdout)
554552

555-
# TODO: RUSTPYTHON
556-
@unittest.expectedFailure
557553
def test_sys_argv_list(self):
558554
with open(TESTFN, 'w', encoding='utf-8') as fd:
559555
self.addCleanup(unlink, TESTFN)
@@ -591,8 +587,6 @@ def f():
591587
self.assertIn('lines cov% module (path)', stdout)
592588
self.assertIn(f'6 100% {modulename} ({filename})', stdout)
593589

594-
# TODO: RUSTPYTHON
595-
@unittest.expectedFailure
596590
def test_run_as_module(self):
597591
assert_python_ok('-m', 'trace', '-l', '--module', 'timeit', '-n', '1')
598592
assert_python_failure('-m', 'trace', '-l', '--module', 'not_a_module_zzz')

vm/src/protocol/callable.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,18 @@ impl VirtualMachine {
103103
self.use_tracing.set(false);
104104
let res = trace_func.call(args.clone(), self);
105105
self.use_tracing.set(true);
106-
res?;
106+
if res.is_err() {
107+
*self.trace_func.borrow_mut() = self.ctx.none();
108+
}
107109
}
108110

109111
if !self.is_none(&profile_func) {
110112
self.use_tracing.set(false);
111113
let res = profile_func.call(args, self);
112114
self.use_tracing.set(true);
113-
res?;
115+
if res.is_err() {
116+
*self.profile_func.borrow_mut() = self.ctx.none();
117+
}
114118
}
115119
Ok(())
116120
}

0 commit comments

Comments
 (0)