(&self, exc: Option<PyBaseExceptionRef>)
| 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() |
no test coverage detected