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

Method _py_panic_failed

crates/vm/src/vm/vm_object.rs:14–53  ·  view source on GitHub ↗
(&self, exc: PyBaseExceptionRef, msg: &str)

Source from the content-addressed store, hash-verified

12 #[track_caller]
13 #[cold]
14 fn _py_panic_failed(&self, exc: PyBaseExceptionRef, msg: &str) -> ! {
15 #[cfg(not(all(
16 target_arch = "wasm32",
17 not(any(target_os = "emscripten", target_os = "wasi")),
18 )))]
19 {
20 self.print_exception(exc);
21 self.flush_std();
22 panic!("{msg}")
23 }
24 #[cfg(all(
25 target_arch = "wasm32",
26 feature = "wasmbind",
27 not(any(target_os = "emscripten", target_os = "wasi")),
28 ))]
29 #[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))]
30 {
31 use wasm_bindgen::prelude::*;
32 #[wasm_bindgen]
33 extern "C" {
34 #[wasm_bindgen(js_namespace = console)]
35 fn error(s: &str);
36 }
37 let mut s = String::new();
38 self.write_exception(&mut s, &exc).unwrap();
39 error(&s);
40 panic!("{msg}; exception backtrace above")
41 }
42 #[cfg(all(
43 target_arch = "wasm32",
44 not(feature = "wasmbind"),
45 not(any(target_os = "emscripten", target_os = "wasi")),
46 ))]
47 {
48 use crate::convert::ToPyObject;
49 let err_string: String = exc.to_pyobject(self).repr(self).unwrap().to_string();
50 eprintln!("{err_string}");
51 panic!("{msg}; python exception not available")
52 }
53 }
54
55 /// Returns true if the file object's `closed` attribute is truthy.
56 fn file_is_closed(&self, file: &PyObject) -> bool {

Callers 2

unwrap_pyresultMethod · 0.80
expect_pyresultMethod · 0.80

Calls 9

newFunction · 0.85
print_exceptionMethod · 0.80
flush_stdMethod · 0.80
write_exceptionMethod · 0.80
to_stringMethod · 0.80
errorFunction · 0.50
unwrapMethod · 0.45
reprMethod · 0.45
to_pyobjectMethod · 0.45

Tested by

no test coverage detected