diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-05-10 00:55:35 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-05-10 00:55:35 +0300 |
commit | 717a9582560a333a60191eb83c61ef179419949f (patch) | |
tree | 9012d5601145828a4b1b593f9cc3141d36d9547a | |
parent | 4ed7b7f751b161420e6979927fd0756467a10cb7 (diff) | |
download | micropython-717a9582560a333a60191eb83c61ef179419949f.tar.gz micropython-717a9582560a333a60191eb83c61ef179419949f.zip |
unix: Print unhandled exception to stderr, like CPython does.
-rw-r--r-- | unix/main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c index 9794f60836..50b6c1e0bb 100644 --- a/unix/main.c +++ b/unix/main.c @@ -73,6 +73,13 @@ STATIC void sighandler(int signum) { } #endif +STATIC void stderr_print_strn(void *env, const char *str, mp_uint_t len) { + (void)env; + fwrite(str, len, 1, stderr); +} + +const mp_print_t mp_stderr_print = {NULL, stderr_print_strn}; + #define FORCED_EXIT (0x100) // If exc is SystemExit, return value where FORCED_EXIT bit set, // and lower 8 bits are SystemExit value. For all other exceptions, @@ -90,7 +97,7 @@ STATIC int handle_uncaught_exception(mp_obj_t exc) { } // Report all other exceptions - mp_obj_print_exception(&mp_plat_print, exc); + mp_obj_print_exception(&mp_stderr_print, exc); return 1; } |