Skip to content

Commit b95de7e

Browse files
committed
fix check_signals
1 parent c676d72 commit b95de7e

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

crates/vm/src/frame.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
bytecode::{
2121
self, ADAPTIVE_BACKOFF_VALUE, Arg, Instruction, LoadAttr, LoadSuperAttr, SpecialMethod,
2222
},
23-
convert::{IntoObject, ToPyObject, ToPyResult},
23+
convert::{ToPyObject, ToPyResult},
2424
coroutine::Coro,
2525
exceptions::ExceptionCtor,
2626
function::{ArgMapping, Either, FuncArgs},
@@ -787,7 +787,33 @@ impl ExecutingFrame<'_> {
787787
}
788788
}
789789

790-
vm.check_signals()?;
790+
if let Err(exception) = vm.check_signals() {
791+
#[cold]
792+
fn handle_signal_exception(
793+
frame: &mut ExecutingFrame<'_>,
794+
exception: PyBaseExceptionRef,
795+
idx: usize,
796+
vm: &VirtualMachine,
797+
) -> FrameResult {
798+
let (loc, _end_loc) = frame.code.locations[idx];
799+
let next = exception.__traceback__();
800+
let new_traceback =
801+
PyTraceback::new(next, frame.object.to_owned(), idx as u32 * 2, loc.line);
802+
exception.set_traceback_typed(Some(new_traceback.into_ref(&vm.ctx)));
803+
vm.contextualize_exception(&exception);
804+
frame.unwind_blocks(vm, UnwindReason::Raising { exception })
805+
}
806+
match handle_signal_exception(self, exception, idx, vm) {
807+
Ok(None) => {}
808+
Ok(Some(value)) => {
809+
break Ok(value);
810+
}
811+
Err(exception) => {
812+
break Err(exception);
813+
}
814+
}
815+
continue;
816+
}
791817
let lasti_before = self.lasti();
792818
let result = self.execute_instruction(op, arg, &mut do_extend_arg, vm);
793819
// Skip inline cache entries if instruction fell through (no jump).

0 commit comments

Comments
 (0)