mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Add MICROPY_KBD_EXCEPTION config option to provide mp_kbd_exception.
Defining and initialising mp_kbd_exception is boiler-plate code and so the core runtime can provide it, instead of each port needing to do it themselves. The exception object is placed in the VM state rather than on the heap.
This commit is contained in:
@@ -68,6 +68,15 @@ void mp_init(void) {
|
||||
mp_init_emergency_exception_buf();
|
||||
#endif
|
||||
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
// initialise the exception object for raising KeyboardInterrupt
|
||||
MP_STATE_VM(mp_kbd_exception).base.type = &mp_type_KeyboardInterrupt;
|
||||
MP_STATE_VM(mp_kbd_exception).traceback_alloc = 0;
|
||||
MP_STATE_VM(mp_kbd_exception).traceback_len = 0;
|
||||
MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
|
||||
MP_STATE_VM(mp_kbd_exception).args = mp_const_empty_tuple;
|
||||
#endif
|
||||
|
||||
// call port specific initialization if any
|
||||
#ifdef MICROPY_PORT_INIT_FUNC
|
||||
MICROPY_PORT_INIT_FUNC;
|
||||
|
||||
Reference in New Issue
Block a user