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.
This commit is contained in:
parent
f4641b2378
commit
abe2caf6df
@ -32,9 +32,6 @@
|
|||||||
int mp_interrupt_char = -1;
|
int mp_interrupt_char = -1;
|
||||||
|
|
||||||
void mp_hal_set_interrupt_char(int c) {
|
void mp_hal_set_interrupt_char(int c) {
|
||||||
if (c != -1) {
|
|
||||||
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
|
|
||||||
}
|
|
||||||
mp_interrupt_char = c;
|
mp_interrupt_char = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +39,6 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mp_hal_set_interrupt_char(int c) {
|
void mp_hal_set_interrupt_char(int c) {
|
||||||
if (c != -1) {
|
|
||||||
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
|
|
||||||
}
|
|
||||||
tud_cdc_set_wanted_char(c);
|
tud_cdc_set_wanted_char(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
#if MICROPY_KBD_EXCEPTION
|
#if MICROPY_KBD_EXCEPTION
|
||||||
|
// This function may be called asynchronously at any time so only do the bare minimum.
|
||||||
void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
|
void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
|
||||||
|
MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
|
||||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
|
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
|
||||||
#if MICROPY_ENABLE_SCHEDULER
|
#if MICROPY_ENABLE_SCHEDULER
|
||||||
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
|
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user