diff options
author | Laurens Valk <laurens@pybricks.com> | 2022-08-19 16:40:28 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-08-23 13:34:06 +1000 |
commit | d8ad87843ab38dcc74e7e86354849fff585e1ba8 (patch) | |
tree | 81906ccc6b70ea3c32aa07fc51ce6a3ce979ebe8 /py/builtinimport.c | |
parent | 3d65101a8a55550bdbaa4df4e216edba238fa299 (diff) |
py/builtinimport: Allow overriding of mp_builtin___import__.
This allows ports to override mp_builtin___import__.
This can be useful in MicroPython applications where
MICROPY_ENABLE_EXTERNAL_IMPORT has to be disabled due to its impact on
build size (2% to 2.5% of the minimal port). By overriding the otherwise
very minimal mp_builtin___import__, ports can still allow limited forms
of application-specific imports.
Signed-off-by: Laurens Valk <laurens@pybricks.com>
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r-- | py/builtinimport.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index 36cdac076..a578d4ad2 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -467,7 +467,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, return module_obj; } -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { +mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) { #if DEBUG_PRINT DEBUG_printf("__import__:\n"); for (size_t i = 0; i < n_args; i++) { @@ -566,7 +566,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { #else // MICROPY_ENABLE_EXTERNAL_IMPORT -mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { +mp_obj_t mp_builtin___import___default(size_t n_args, const mp_obj_t *args) { // Check that it's not a relative import if (n_args >= 5 && MP_OBJ_SMALL_INT_VALUE(args[4]) != 0) { mp_raise_NotImplementedError(MP_ERROR_TEXT("relative import")); |