8000 py/scheduler: Move clearing of kbd traceback to mp_keyboard_interrupt. · jeremyherbert/micropython@abe2caf · GitHub
[go: up one dir, main page]

Skip to content

Commit abe2caf

Browse files
committed
py/scheduler: Move clearing of kbd traceback to mp_keyboard_interrupt.
This is a more logical place to clear the KeyboardInterrupt traceback, right before it is set as a pending exception. The clearing is also optimised from a function call to a simple store of NULL.
1 parent f4641b2 commit abe2caf

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

lib/utils/interrupt_char.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
int mp_interrupt_char = -1;
3333

3434
void mp_hal_set_interrupt_char(int c) {
35-
if (c != -1) {
36-
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
37-
}
3835
mp_interrupt_char = c;
3936
}
4037

ports/samd/mphalport.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
3939
}
4040

4141
void mp_hal_set_interrupt_char(int c) {
42-
if (c != -1) {
43-
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
44-
}
4542
tud_cdc_set_wanted_char(c);
4643
}
4744

py/scheduler.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include "py/runtime.h"
3030

3131
#if MICROPY_KBD_EXCEPTION
32+
// This function may be called asynchronously at any time so only do the bare minimum.
3233
void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
34+
MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
3335
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
3436
#if MICROPY_ENABLE_SCHEDULER
3537
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {

0 commit comments

Comments
 (0)
0