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

Method set_exception

crates/vm/src/vm/mod.rs:2062–2079  ·  view source on GitHub ↗
(&self, exc: Option<PyBaseExceptionRef>)

Source from the content-addressed store, hash-verified

2060 }
2061
2062 pub(crate) fn set_exception(&self, exc: Option<PyBaseExceptionRef>) {
2063 // don't be holding the RefCell guard while __del__ is called
2064 let mut excs = self.exceptions.borrow_mut();
2065 debug_assert!(
2066 !excs.stack.is_empty(),
2067 "set_exception called with empty exception stack"
2068 );
2069 if let Some(top) = excs.stack.last_mut() {
2070 let prev = core::mem::replace(top, exc);
2071 drop(excs);
2072 drop(prev);
2073 } else {
2074 excs.stack.push(exc);
2075 drop(excs);
2076 }
2077 #[cfg(feature = "threading")]
2078 thread::update_thread_exception(self.topmost_exception());
2079 }
2080
2081 pub(crate) fn contextualize_exception(&self, exception: &Py<PyBaseException>) {
2082 if let Some(context_exc) = self.topmost_exception()

Callers 3

execute_instructionMethod · 0.45
execute_instrumentedMethod · 0.45

Calls 5

update_thread_exceptionFunction · 0.85
borrow_mutMethod · 0.80
topmost_exceptionMethod · 0.80
replaceFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected