summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/builtinimport.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 4fee04b8f..d4cd254fd 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -632,12 +632,17 @@ mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) {
return elem->value;
}
- // Try the name directly as a built-in.
+ // Try the name directly as a non-extensible built-in (e.g. `micropython`).
qstr module_name_qstr = mp_obj_str_get_qstr(args[0]);
mp_obj_t module_obj = mp_module_get_builtin(module_name_qstr, false);
if (module_obj != MP_OBJ_NULL) {
return module_obj;
}
+ // Now try as an extensible built-in (e.g. `time`).
+ module_obj = mp_module_get_builtin(module_name_qstr, true);
+ if (module_obj != MP_OBJ_NULL) {
+ return module_obj;
+ }
// Couldn't find the module, so fail
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE