summaryrefslogtreecommitdiff
path: root/py/modmicropython.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-09-27 13:34:21 +1000
committerDamien George <damien.p.george@gmail.com>2016-09-27 13:34:21 +1000
commit791b65f4b261a23e427664f0b86ce32b60e33cb5 (patch)
tree87a8a76e78bb440977d437637e98c1e9f3aaaf1b /py/modmicropython.c
parentf65e4f0b8fbd3992da6cf8a69e89e3bad3001d36 (diff)
py/modmicropython: Add micropython.const, alias for identity function.
Having a micropython.const identity function, and writing "from micropython import const" at the start of scripts that use the const feature, allows to write scripts which are compatible with CPython, and with uPy builds that don't include const optimisation. This patch adds such a function and updates the tests to do the import.
Diffstat (limited to 'py/modmicropython.c')
-rw-r--r--py/modmicropython.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/modmicropython.c b/py/modmicropython.c
index 31ae7025f..f7d74db2e 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -120,6 +120,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_
STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) },
+ { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) },
#if MICROPY_PY_MICROPYTHON_MEM_INFO
#if MICROPY_MEM_STATS
{ MP_ROM_QSTR(MP_QSTR_mem_total), MP_ROM_PTR(&mp_micropython_mem_total_obj) },