Commit 81e70a88 authored by Damien George's avatar Damien George
Browse files

py: Make REPL printing function print repr of object, not str.

Addresses issue #1014.
parent 0d3cb672
......@@ -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);
extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
pfenv_t pfenv; = &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);
mp_obj_print(o, PRINT_REPR);
return mp_const_none;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment