mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Don't pop exeption for context
This commit is contained in:
@@ -739,8 +739,8 @@ impl Frame {
|
||||
};
|
||||
let context = match argc {
|
||||
0 => vm.get_none(), // We have already got the exception,
|
||||
_ => match vm.pop_exception() {
|
||||
Some(exc) => exc,
|
||||
_ => match vm.last_exception() {
|
||||
Some(exc) => exc.clone(),
|
||||
None => vm.get_none(),
|
||||
},
|
||||
};
|
||||
|
||||
11
vm/src/vm.rs
11
vm/src/vm.rs
@@ -931,6 +931,17 @@ impl VirtualMachine {
|
||||
pub fn pop_exception(&self) -> Option<PyObjectRef> {
|
||||
self.exceptions.borrow_mut().pop()
|
||||
}
|
||||
|
||||
pub fn last_exception(&self) -> Option<Ref<PyObjectRef>> {
|
||||
let exceptions = self.exceptions.borrow();
|
||||
if exceptions.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(Ref::map(self.exceptions.borrow(), |exceptions| {
|
||||
exceptions.last().unwrap()
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for VirtualMachine {
|
||||
|
||||
Reference in New Issue
Block a user