summaryrefslogtreecommitdiff
path: root/py/objmodule.c
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-04-17 13:27:48 -0400
committerLucian Copeland <hierophect@gmail.com>2020-04-17 13:27:48 -0400
commit25245bc44204856c6fd834d7d2bc30187a77bc3a (patch)
tree61995279880cd0a49b797d0ad3897a38e3312bbc /py/objmodule.c
parent3c50098dfc353b0f30f3a743d45dce9de95e060a (diff)
parent1a71c8c51577cc7014d5db1c05084778c0b977e9 (diff)
Merge remote-tracking branch 'upstream/master' into stm32-docfix
Diffstat (limited to 'py/objmodule.c')
-rw-r--r--py/objmodule.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/py/objmodule.c b/py/objmodule.c
index 627ba79e8..b6a8a084e 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -69,6 +69,13 @@ STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
// delete/store attribute
mp_obj_dict_t *dict = self->globals;
if (dict->map.is_fixed) {
+ mp_map_elem_t *elem = mp_map_lookup(&dict->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
+ // Return success if the given value is already in the dictionary. This is the case for
+ // native packages with native submodules.
+ if (elem != NULL && elem->value == dest[1]) {
+ dest[0] = MP_OBJ_NULL; // indicate success
+ return;
+ } else
#if MICROPY_CAN_OVERRIDE_BUILTINS
if (dict == &mp_module_builtins_globals) {
if (MP_STATE_VM(mp_module_builtins_override_dict) == NULL) {
@@ -206,6 +213,14 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
{ MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
#endif
#endif
+#if CIRCUITPY_ULAB
+#if CIRCUITPY
+// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
+// TODO: move to shared-bindings/
+#else
+ { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) },
+#endif
+#endif
#if MICROPY_PY_URE
#if CIRCUITPY
// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.