Skip to content

Commit 3eb7a26

Browse files
committed
py/modthread: Properly cast concrete exception pointer to an object.
1 parent a791be9 commit 3eb7a26

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

py/modthread.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ STATIC void *thread_entry(void *args_in) {
8080
} else {
8181
// uncaught exception
8282
// check for SystemExit
83-
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
83+
mp_obj_base_t *exc = (mp_obj_base_t*)nlr.ret_val;
84+
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
8485
// swallow exception silently
8586
} else {
8687
// print exception out
8788
mp_printf(&mp_plat_print, "Unhandled exception in thread started by ");
8889
mp_obj_print_helper(&mp_plat_print, args->fun, PRINT_REPR);
8990
mp_printf(&mp_plat_print, "\n");
90-
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
91+
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc));
9192
}
9293
}
9394

0 commit comments

Comments
 (0)