Skip to content

Commit 5ae3ddc

Browse files
committed
unix/main: Check pending exception at the end of code block execution.
Usually this checking is done by VM on jump instructions, but for linear sequences of instructions and builtin functions this won't happen. Particular target of this change is long-running builtin functions like time.sleep().
1 parent 66b9682 commit 5ae3ddc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

unix/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
121121
if (!compile_only) {
122122
// execute it
123123
mp_call_function_0(module_fun);
124+
// check for pending exception
125+
if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) {
126+
mp_obj_t obj = MP_STATE_VM(mp_pending_exception);
127+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
128+
nlr_raise(obj);
129+
}
124130
}
125131

126132
mp_hal_set_interrupt_char(-1);

0 commit comments

Comments
 (0)