summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@unpythonic.net>2025-09-26 10:23:06 -0500
committerDamien George <damien@micropython.org>2025-10-04 16:22:32 +1000
commit41284577ca389c463a3e69302de8ad0edaf97f24 (patch)
treee588263e8bc49c14c5c9cbb04e00e69b6a558492 /py/builtinimport.c
parent653f7784d7e566531ed1678486631c6c89aeedb7 (diff)
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>
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 57b5c14e8..ff894f69d 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -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