aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2020-02-07 12:50:57 +1100
committerDamien George2020-02-07 16:08:33 +1100
commit046ae80bdfc3bf4f278f3cc0fb29dc82ad91ec33 (patch)
tree41c926ee2a57d54967ec2745c84d5837479a0b70
parentabe2caf6df4cc98e540d9c05b4f2bce14cdedfa4 (diff)
unix, windows: Use mp_keyboard_interrupt instead of custom code.
The mp_keyboard_interrupt() function does exactly what is needed here, and using it gets ctrl-C working when MICROPY_ENABLE_SCHEDULER is enabled on these ports (and MICROPY_ASYNC_KBD_INTR is disabled).
-rw-r--r--ports/unix/unix_mphal.c3
-rw-r--r--ports/windows/windows_mphal.c5
2 files changed, 3 insertions, 5 deletions
diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c
index 25d1b022d..8fabb339d 100644
--- a/ports/unix/unix_mphal.c
+++ b/ports/unix/unix_mphal.c
@@ -58,8 +58,7 @@ STATIC void sighandler(int signum) {
// this is the second time we are called, so die straight away
exit(1);
}
- mp_obj_exception_clear_traceback(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));
+ mp_keyboard_interrupt();
#endif
}
}
diff --git a/ports/windows/windows_mphal.c b/ports/windows/windows_mphal.c
index 6de888085..e0c125524 100644
--- a/ports/windows/windows_mphal.c
+++ b/ports/windows/windows_mphal.c
@@ -25,7 +25,7 @@
*/
-#include "py/mpstate.h"
+#include "py/runtime.h"
#include "py/mphal.h"
#include "py/mpthread.h"
@@ -84,8 +84,7 @@ BOOL WINAPI console_sighandler(DWORD evt) {
// this is the second time we are called, so die straight away
exit(1);
}
- mp_obj_exception_clear_traceback(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));
+ mp_keyboard_interrupt();
return TRUE;
}
return FALSE;