diff --git a/py/modthread.c b/py/modthread.c index 7742ff68471f1..2c30d59f21a09 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -189,10 +189,8 @@ static void *thread_entry(void *args_in) { // swallow exception silently } else { // print exception out - 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)); + mp_printf(MICROPY_ERROR_PRINTER, "Unhandled exception in thread started by %R\n%K", + PRINT_REPR, args->fun, MP_OBJ_FROM_PTR(exc)); } } diff --git a/py/mpprint.c b/py/mpprint.c index 86dbfad05e30c..5c0c4d9c70272 100644 --- a/py/mpprint.c +++ b/py/mpprint.c @@ -475,6 +475,17 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) { chrs += mp_print_strn(print, &str, 1, flags, fill, width); break; } + case 'K': { + mp_obj_t obj = va_arg(args, mp_obj_t); + mp_obj_print_exception(print, obj); + break; + } + case 'R': { + mp_print_kind_t kind = va_arg(args, int); + mp_obj_t obj = va_arg(args, mp_obj_t); + mp_obj_print_helper(print, obj, kind); + break; + } case 'q': { qstr qst = va_arg(args, qstr); size_t len; diff --git a/py/objattrtuple.c b/py/objattrtuple.c index 1280e3308938e..861eec73f7a79 100644 --- a/py/objattrtuple.c +++ b/py/objattrtuple.c @@ -38,8 +38,7 @@ void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, if (i > 0) { mp_print_str(print, ", "); } - mp_printf(print, "%q=", fields[i]); - mp_obj_print_helper(print, o->items[i], PRINT_REPR); + mp_printf(print, "%q=%R", fields[i], PRINT_REPR, o->items[i]); } mp_print_str(print, ")"); } diff --git a/py/objboundmeth.c b/py/objboundmeth.c index e3503ff154a65..d364192921ecd 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -39,11 +39,7 @@ typedef struct _mp_obj_bound_meth_t { static void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { (void)kind; mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "self, PRINT_REPR); - mp_print_str(print, "."); - mp_obj_print_helper(print, o->meth, PRINT_REPR); - mp_print_str(print, ">"); + mp_printf(print, "", o, PRINT_REPR, o->self, PRINT_REPR, o->meth); } #endif diff --git a/py/objcell.c b/py/objcell.c index 95966c7917cb7..a9718d7c66273 100644 --- a/py/objcell.c +++ b/py/objcell.c @@ -30,13 +30,7 @@ static void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { (void)kind; mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in); - mp_printf(print, "obj); - if (o->obj == MP_OBJ_NULL) { - mp_print_str(print, "(nil)"); - } else { - mp_obj_print_helper(print, o->obj, PRINT_REPR); - } - mp_print_str(print, ">"); + mp_printf(print, "", o->obj, PRINT_REPR, o->obj); } #endif diff --git a/py/objclosure.c b/py/objclosure.c index 3ba507b959382..3948e1d2a2184 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -63,16 +63,10 @@ static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const static void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { (void)kind; mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in); - mp_print_str(print, "fun, PRINT_REPR); - mp_printf(print, " at %p, n_closed=%u ", o, (int)o->n_closed); + mp_printf(print, "fun, o, (int)o->n_closed); for (size_t i = 0; i < o->n_closed; i++) { - if (o->closed[i] == MP_OBJ_NULL) { - mp_print_str(print, "(nil)"); - } else { - mp_obj_print_helper(print, o->closed[i], PRINT_REPR); - } mp_print_str(print, " "); + mp_obj_print_helper(print, o->closed[i], PRINT_REPR); } mp_print_str(print, ">"); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy