MCPcopy Index your code
hub / github.com/RustPython/RustPython / fire_exception_trace

Method fire_exception_trace

crates/vm/src/frame.rs:1422–1434  ·  view source on GitHub ↗

Fire 'exception' trace event (sys.settrace) with (type, value, traceback) tuple. Matches `_PyEval_MonitorRaise` → `PY_MONITORING_EVENT_RAISE` → `sys_trace_exception_func` in legacy_tracing.c.

(&self, exc: &PyBaseExceptionRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1420 /// Matches `_PyEval_MonitorRaise` → `PY_MONITORING_EVENT_RAISE` →
1421 /// `sys_trace_exception_func` in legacy_tracing.c.
1422 fn fire_exception_trace(&self, exc: &PyBaseExceptionRef, vm: &VirtualMachine) -> PyResult<()> {
1423 if vm.use_tracing.get() && !vm.is_none(&self.object.trace.lock()) {
1424 let exc_type: PyObjectRef = exc.class().to_owned().into();
1425 let exc_value: PyObjectRef = exc.clone().into();
1426 let exc_tb: PyObjectRef = exc
1427 .__traceback__()
1428 .map(|tb| -> PyObjectRef { tb.into() })
1429 .unwrap_or_else(|| vm.ctx.none());
1430 let tuple = vm.ctx.new_tuple(vec![exc_type, exc_value, exc_tb]).into();
1431 vm.trace_event(crate::protocol::TraceEvent::Exception, Some(tuple))?;
1432 }
1433 Ok(())
1434 }
1435
1436 fn run(&mut self, vm: &VirtualMachine) -> PyResult<ExecutionResult> {
1437 flame_guard!(format!(

Callers 3

runMethod · 0.80
execute_instructionMethod · 0.80
execute_for_iterMethod · 0.80

Calls 12

__traceback__Method · 0.80
noneMethod · 0.80
trace_eventMethod · 0.80
SomeClass · 0.50
getMethod · 0.45
is_noneMethod · 0.45
lockMethod · 0.45
to_ownedMethod · 0.45
classMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected