diff --git a/py/obj.c b/py/obj.c index 4d363e8a69..dad27b8772 100644 --- a/py/obj.c +++ b/py/obj.c @@ -37,6 +37,7 @@ #include "py/runtime.h" #include "py/stackctrl.h" #include "py/pfenv.h" +#include "py/stream.h" // for mp_obj_print mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { if (MP_OBJ_IS_SMALL_INT(o_in)) { @@ -71,7 +72,14 @@ void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *e } void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { - mp_obj_print_helper(printf_wrapper, NULL, o_in, kind); + // defined per port; type of these is irrelevant, just need pointer + extern mp_uint_t mp_sys_stdout_obj; + + pfenv_t pfenv; + pfenv.data = &mp_sys_stdout_obj; + pfenv.print_strn = (void (*)(void *, const char *, mp_uint_t))mp_stream_write; + + mp_obj_print_helper((void (*)(void *env, const char *fmt, ...))pfenv_printf, &pfenv, o_in, kind); } // helper function to print an exception with traceback