summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-10-12 21:49:03 +0100
committerDamien George <damien.p.george@gmail.com>2015-10-17 12:55:25 +0100
commit035a0a2b6e5e3e6908927d3627887fbd581b7469 (patch)
treefd12ce992de5778632b210179582d15e246cd28f /py
parente813541e3f8a65fcc6e1b666e6547bd10b3dc316 (diff)
downloadmicropython-035a0a2b6e5e3e6908927d3627887fbd581b7469.tar.gz
micropython-035a0a2b6e5e3e6908927d3627887fbd581b7469.zip
py: Add support for _ in REPL to hold last computed value.
Only available when MICROPY_CAN_OVERRIDE_BUILTINS is enabled.
Diffstat (limited to 'py')
-rw-r--r--py/modbuiltins.c4
-rw-r--r--py/qstrdefs.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 1f33ab75ec..45fb3ffd9b 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -416,6 +416,10 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
mp_obj_print_helper(&mp_plat_print, o, PRINT_REPR);
mp_print_str(&mp_plat_print, "\n");
#endif
+ #if MICROPY_CAN_OVERRIDE_BUILTINS
+ mp_obj_t dest[2] = {MP_OBJ_SENTINEL, o};
+ mp_type_module.attr((mp_obj_t)&mp_module_builtins, MP_QSTR__, dest);
+ #endif
}
return mp_const_none;
}
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index dcde1b5c16..161d231127 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -35,6 +35,7 @@ QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH)
Q()
Q(*)
+Q(_)
Q(__build_class__)
Q(__class__)
Q(__doc__)