mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
py/makemoduledefs.py: Avoid empty extensible module lists.
An empty array is a C extension supported by clang & GCC but not MSVC. This also saves a bit of code size if there are no extensible modules. Fixes issue #18141. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
committed by
Damien George
parent
653f7784d7
commit
41284577ca
@@ -403,6 +403,7 @@ static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
|
||||
// all the locations in sys.path.
|
||||
stat = stat_top_level(level_mod_name, &path);
|
||||
|
||||
#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
|
||||
// If filesystem failed, now try and see if it matches an extensible
|
||||
// built-in module.
|
||||
if (stat == MP_IMPORT_STAT_NO_EXIST) {
|
||||
@@ -411,6 +412,7 @@ static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
|
||||
return module_obj;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
DEBUG_printf("Searching for sub-module\n");
|
||||
|
||||
@@ -646,11 +648,13 @@ mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) {
|
||||
if (module_obj != MP_OBJ_NULL) {
|
||||
return module_obj;
|
||||
}
|
||||
#if MICROPY_HAVE_REGISTERED_EXTENSIBLE_MODULES
|
||||
// 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Couldn't find the module, so fail
|
||||
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
|
||||
|
||||
Reference in New Issue
Block a user