From 81e70a88a7a4adb33c4a5d049c83f42d94e6332b Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 28 Jan 2015 23:53:13 +0000 Subject: [PATCH] py: Make REPL printing function print repr of object, not str. Addresses issue #1014. --- py/modbuiltins.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index d537d49dea..b876ca32da 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -442,7 +442,17 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print); STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { if (o != mp_const_none) { - mp_builtin_print(1, &o, (mp_map_t*)&mp_const_empty_map); + #if MICROPY_PY_IO + extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer + 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, PRINT_REPR); + mp_stream_write(&mp_sys_stdout_obj, "\n", 1); + #else + mp_obj_print(o, PRINT_REPR); + printf("\n"); + #endif } return mp_const_none; }