py/builtinimport: Fix built-in imports when external import is disabled.
Follow-up to 24c02c4eb5f11200f876bb57cd63a9d0bae91fd3 for when MICROPY_ENABLE_EXTERNAL_IMPORT=0. It now needs to try both extensible and non-extensible modules. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
606ec9bfb1
commit
671b35ceae
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user