8000 Ctrl-C was causing a soft-reset in REPL. · sparkfun/circuitpython@acbca44 · GitHub
[go: up one dir, main page]

Skip to content

Commit acbca44

Browse files
dhalberttannewt
authored andcommitted
Ctrl-C was causing a soft-reset in REPL.
Also allow an immediate ctrl-c in `input()`.
1 parent c0159c5 commit acbca44

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

atmel-samd/mphalport.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "lib/utils/interrupt_char.h"
1212
#include "py/mphal.h"
1313
#include "py/mpstate.h"
14+
#include "py/runtime.h"
1415
#include "py/smallint.h"
1516
#include "shared-bindings/time/__init__.h"
1617

@@ -157,6 +158,11 @@ int mp_hal_stdin_rx_chr(void) {
157158
#ifdef MICROPY_VM_HOOK_LOOP
158159
MICROPY_VM_HOOK_LOOP
159160
#endif
161+
// Check to see if we've been CTRL-Ced by autoreload or the user. Raise the exception if so.
162+
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
163+
mp_handle_pending();
164+
}
165+
160166
#ifdef USB_REPL
161167
if (reload_next_character) {
162168
return CHAR_CTRL_D;

lib/utils/pyexec.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
121121
} else {
122122
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
123123
ret = PYEXEC_EXCEPTION;
124-
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_KeyboardInterrupt)) {
125-
ret = PYEXEC_FORCED_EXIT;
126-
}
127124
}
128125
}
129126
if (result != NULL) {

0 commit comments

Comments
 (0)
0