From 3eb7a268091ef68248d58ddb3ad11465f1cb2199 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Sat, 23 Apr 2016 12:24:44 +0000
Subject: [PATCH] py/modthread: Properly cast concrete exception pointer to an
 object.

---
 py/modthread.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/py/modthread.c b/py/modthread.c
index 5104ef127..5d01fe601 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -80,14 +80,15 @@ STATIC void *thread_entry(void *args_in) {
     } else {
         // uncaught exception
         // check for SystemExit
-        if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
+        mp_obj_base_t *exc = (mp_obj_base_t*)nlr.ret_val;
+        if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
             // swallow exception silently
         } else {
             // print exception out
             mp_printf(&mp_plat_print, "Unhandled exception in thread started by ");
             mp_obj_print_helper(&mp_plat_print, args->fun, PRINT_REPR);
             mp_printf(&mp_plat_print, "\n");
-            mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
+            mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc));
         }
     }
 
-- 
GitLab