diff options
author | Paul m. p. P <pmpp.pub@gmail.com> | 2019-07-19 00:56:40 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-07-31 22:37:44 +1000 |
commit | f60229e261e61b59d563023b2df7204c4e01c51c (patch) | |
tree | 30725b0f4b81c5ff0ad0ca347dcd7bc66cdbdf55 /py/modio.c | |
parent | 60f1063797716cfec14c84afafec69bf06127777 (diff) |
py/modio: Call mp_import_name to do resource stream import.
So code is not duplicated and it can take advantage of __import__ being
overridden.
Diffstat (limited to 'py/modio.c')
-rw-r--r-- | py/modio.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/py/modio.c b/py/modio.c index 0f4a4326c..94ef5d42e 100644 --- a/py/modio.c +++ b/py/modio.c @@ -208,15 +208,8 @@ STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) { // package parameter being None, the path_in is interpreted as a // raw path. if (package_in != mp_const_none) { - mp_obj_t args[5]; - args[0] = package_in; - args[1] = mp_const_none; // TODO should be globals - args[2] = mp_const_none; // TODO should be locals - args[3] = mp_const_true; // Pass sentinel "non empty" value to force returning of leaf module - args[4] = MP_OBJ_NEW_SMALL_INT(0); - - // TODO lookup __import__ and call that instead of going straight to builtin implementation - mp_obj_t pkg = mp_builtin___import__(5, args); + // Pass "True" as sentinel value in fromlist to force returning of leaf module + mp_obj_t pkg = mp_import_name(mp_obj_str_get_qstr(package_in), mp_const_true, MP_OBJ_NEW_SMALL_INT(0)); mp_obj_t dest[2]; mp_load_method_maybe(pkg, MP_QSTR___path__, dest); |