summaryrefslogtreecommitdiffstatshomepage
path: root/lib/utils
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-02-06 01:06:59 +1100
committerDamien George <damien.p.george@gmail.com>2020-02-07 16:08:26 +1100
commit5a91cd9ff3e97b74ad6c9a615f810b8fcebbe110 (patch)
treef23b7aa26cf36010f8ac1415900609e83dc24bb6 /lib/utils
parent98a3911c430b0cc96e1821d7ca589b9be3355fc3 (diff)
downloadmicropython-5a91cd9ff3e97b74ad6c9a615f810b8fcebbe110.tar.gz
micropython-5a91cd9ff3e97b74ad6c9a615f810b8fcebbe110.zip
lib/utils/pyexec: Handle pending exceptions after disabling kbd intrs.
Pending exceptions would otherwise be handled later on where there may not be an NLR handler in place. A similar fix is also made to the unix port's REPL handler. Fixes issues #4921 and #5488.
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/pyexec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c
index 747097f157..0c9e9791c1 100644
--- a/lib/utils/pyexec.c
+++ b/lib/utils/pyexec.c
@@ -107,6 +107,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
#endif
mp_call_function_0(module_fun);
mp_hal_set_interrupt_char(-1); // disable interrupt
+ mp_handle_pending(true); // handle any pending exceptions (and any callbacks)
nlr_pop();
ret = 1;
if (exec_flags & EXEC_FLAG_PRINT_EOF) {
@@ -114,8 +115,8 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
}
} else {
// uncaught exception
- // FIXME it could be that an interrupt happens just before we disable it here
mp_hal_set_interrupt_char(-1); // disable interrupt
+ mp_handle_pending(false); // clear any pending exceptions (and run any callbacks)
// print EOF after normal output
if (exec_flags & EXEC_FLAG_PRINT_EOF) {
mp_hal_stdout_tx_strn("\x04", 1);