diff options
author | David Lechner <david@lechnology.com> | 2017-09-24 20:15:48 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-09-26 11:59:11 +1000 |
commit | 62849b7010abffb7b0a9c9875930efe7cb77519c (patch) | |
tree | df719db4ca96bffd7bad42f0823feaf9cc30f81a /py/modthread.c | |
parent | 9d836fedbdb1d28bdfc4ba475bbdfc1adb3f007a (diff) | |
download | micropython-62849b7010abffb7b0a9c9875930efe7cb77519c.tar.gz micropython-62849b7010abffb7b0a9c9875930efe7cb77519c.zip |
py: Add config option to print warnings/errors to stderr.
This adds a new configuration option to print runtime warnings and errors to
stderr. On Unix, CPython prints warnings and unhandled exceptions to stderr,
so the unix port here is configured to use this option.
The unix port already printed unhandled exceptions on the main thread to
stderr. This patch fixes unhandled exceptions on other threads and warnings
(issue #2838) not printing on stderr.
Additionally, a couple tests needed to be fixed to handle this new behavior.
This is done by also capturing stderr when running tests.
Diffstat (limited to 'py/modthread.c')
-rw-r--r-- | py/modthread.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/py/modthread.c b/py/modthread.c index bf74128e81..cb071d0f86 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -192,10 +192,10 @@ STATIC void *thread_entry(void *args_in) { // 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_FROM_PTR(exc)); + mp_printf(MICROPY_ERROR_PRINTER, "Unhandled exception in thread started by "); + mp_obj_print_helper(MICROPY_ERROR_PRINTER, args->fun, PRINT_REPR); + mp_printf(MICROPY_ERROR_PRINTER, "\n"); + mp_obj_print_exception(MICROPY_ERROR_PRINTER, MP_OBJ_FROM_PTR(exc)); } } |