summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-06-05 16:52:29 +1000
committerJim Mussared <jim.mussared@gmail.com>2023-06-08 17:54:24 +1000
commit5e50975a6dd9466afafbcd012c00078093fe1f57 (patch)
tree92e29c7c944b69ed94c3f161c6c8519d5e7bed15 /py/builtinimport.c
parent7d2ee8aed0cc5ba1a0041ac4cc7631898aaf252f (diff)
py/modsys: Allow sys.path to be assigned to.
Previously sys.path could be modified by append/pop or slice assignment. This allows `sys.path = [...]`, which can be simpler in many cases, but also improves CPython compatibility. It also allows sys.path to be set to a tuple which means that you can clear sys.path (e.g. temporarily) with no allocations. This also makes sys.path (and sys.argv for consistency) able to be disabled via mpconfig. The unix port (and upytesthelper) require them, so they explicitly verify that they're enabled. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 8a125fc53..4fee04b8f 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -118,7 +118,7 @@ STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
#if MICROPY_PY_SYS
size_t path_num;
mp_obj_t *path_items;
- mp_obj_list_get(mp_sys_path, &path_num, &path_items);
+ mp_obj_get_array(mp_sys_path, &path_num, &path_items);
// go through each sys.path entry, trying to import "<entry>/<mod_name>".
for (size_t i = 0; i < path_num; i++) {
@@ -365,7 +365,7 @@ STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
// which may have come from the filesystem.
size_t path_num;
mp_obj_t *path_items;
- mp_obj_list_get(mp_sys_path, &path_num, &path_items);
+ mp_obj_get_array(mp_sys_path, &path_num, &path_items);
if (path_num)
#endif
{