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

Method run_unraisable

crates/vm/src/vm/mod.rs:1114–1139  ·  view source on GitHub ↗
(&self, e: PyBaseExceptionRef, msg: Option<String>, object: PyObjectRef)

Source from the content-addressed store, hash-verified

1112
1113 #[cold]
1114 pub fn run_unraisable(&self, e: PyBaseExceptionRef, msg: Option<String>, object: PyObjectRef) {
1115 // During interpreter finalization, sys.unraisablehook may not be available,
1116 // but we still need to report exceptions (especially from atexit callbacks).
1117 // Write directly to stderr like PyErr_FormatUnraisable.
1118 if self.state.finalizing.load(Ordering::Acquire) {
1119 self.write_unraisable_to_stderr(&e, msg.as_deref(), &object);
1120 return;
1121 }
1122
1123 let sys_module = self.import("sys", 0).unwrap();
1124 let unraisablehook = sys_module.get_attr("unraisablehook", self).unwrap();
1125
1126 let exc_type = e.class().to_owned();
1127 let exc_traceback = e.__traceback__().to_pyobject(self); // TODO: actual traceback
1128 let exc_value = e.into();
1129 let args = stdlib::sys::UnraisableHookArgsData {
1130 exc_type,
1131 exc_value,
1132 exc_traceback,
1133 err_msg: self.new_pyobj(msg),
1134 object,
1135 };
1136 if let Err(e) = unraisablehook.call((args,), self) {
1137 println!("{}", e.as_object().repr(self).unwrap());
1138 }
1139 }
1140
1141 /// Write unraisable exception to stderr during finalization.
1142 /// Similar to _PyErr_WriteUnraisableDefaultHook in CPython.

Callers 15

_servername_callbackFunction · 0.80
_msg_callbackFunction · 0.80
delMethod · 0.80
invoke_sni_callbackMethod · 0.80
collect_innerMethod · 0.80
iobase_finalizeFunction · 0.80
dealloc_warnMethod · 0.80
_run_exitfuncsFunction · 0.80
run_at_forkersFunction · 0.80
run_threadFunction · 0.80
_shutdownFunction · 0.80
start_joinable_threadFunction · 0.80

Calls 11

__traceback__Method · 0.80
new_pyobjMethod · 0.80
loadMethod · 0.45
unwrapMethod · 0.45
importMethod · 0.45
get_attrMethod · 0.45
to_ownedMethod · 0.45
classMethod · 0.45
to_pyobjectMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected