mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
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>
This commit is contained in:
@@ -227,8 +227,13 @@ int mp_native_type_from_qstr(qstr qst);
|
||||
mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type);
|
||||
mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type);
|
||||
|
||||
#define mp_sys_path (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_path_obj)))
|
||||
#if MICROPY_PY_SYS_PATH
|
||||
#define mp_sys_path (MP_STATE_VM(sys_mutable[MP_SYS_MUTABLE_PATH]))
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_SYS_ARGV
|
||||
#define mp_sys_argv (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_argv_obj)))
|
||||
#endif
|
||||
|
||||
#if MICROPY_WARNINGS
|
||||
#ifndef mp_warning
|
||||
|
||||
Reference in New Issue
Block a user