summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-20 17:56:58 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-20 17:56:58 +1100
commit6e7819ee2ee20ec9f09feb40b68be5973797f874 (patch)
tree677628d5de061d30f30ba2337af435d9943e73f3 /py/builtinimport.c
parent27fa9881a9294c6a6875856c44101e5b33d27a3b (diff)
py/objmodule: Factor common code for calling __init__ on builtin module.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 97c1789f8..19bc9fc95 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -389,19 +389,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
}
// found weak linked module
module_obj = el->value;
- if (MICROPY_MODULE_BUILTIN_INIT) {
- // look for __init__ and call it if it exists
- // Note: this code doesn't work fully correctly because it allows the
- // __init__ function to be called twice if the module is imported by its
- // non-weak-link name. Also, this code is duplicated in objmodule.c.
- mp_obj_t dest[2];
- mp_load_method_maybe(el->value, MP_QSTR___init__, dest);
- if (dest[0] != MP_OBJ_NULL) {
- mp_call_method_n_kw(0, 0, dest);
- // register module so __init__ is not called again
- mp_module_register(mod_name, el->value);
- }
- }
+ mp_module_call_init(mod_name, module_obj);
} else {
no_exist:
#else