Skip to content

Commit 717a958

Browse files
committed
unix: Print unhandled exception to stderr, like CPython does.
1 parent 4ed7b7f commit 717a958

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

unix/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ STATIC void sighandler(int signum) {
7373
}
7474
#endif
7575

76+
STATIC void stderr_print_strn(void *env, const char *str, mp_uint_t len) {
77+
(void)env;
78+
fwrite(str, len, 1, stderr);
79+
}
80+
81+
const mp_print_t mp_stderr_print = {NULL, stderr_print_strn};
82+
7683
#define FORCED_EXIT (0x100)
7784
// If exc is SystemExit, return value where FORCED_EXIT bit set,
7885
// and lower 8 bits are SystemExit value. For all other exceptions,
@@ -90,7 +97,7 @@ STATIC int handle_uncaught_exception(mp_obj_t exc) {
9097
}
9198

9299
// Report all other exceptions
93-
mp_obj_print_exception(&mp_plat_print, exc);
100+
mp_obj_print_exception(&mp_stderr_print, exc);
94101
return 1;
95102
}
96103

0 commit comments

Comments
 (0)