Skip to content

Commit 035a0a2

Browse files
committed
py: Add support for _ in REPL to hold last computed value.
Only available when MICROPY_CAN_OVERRIDE_BUILTINS is enabled.
1 parent e813541 commit 035a0a2

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

py/modbuiltins.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
416416
mp_obj_print_helper(&mp_plat_print, o, PRINT_REPR);
417417
mp_print_str(&mp_plat_print, "\n");
418418
#endif
419+
#if MICROPY_CAN_OVERRIDE_BUILTINS
420+
mp_obj_t dest[2] = {MP_OBJ_SENTINEL, o};
421+
mp_type_module.attr((mp_obj_t)&mp_module_builtins, MP_QSTR__, dest);
422+
#endif
419423
}
420424
return mp_const_none;
421425
}

py/qstrdefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ QCFG(BYTES_IN_HASH, MICROPY_QSTR_BYTES_IN_HASH)
3535

3636
Q()
3737
Q(*)
38+
Q(_)
3839
Q(__build_class__)
3940
Q(__class__)
4041
Q(__doc__)

0 commit comments

Comments
 (0)