summaryrefslogtreecommitdiff
path: root/py/modsys.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-07 17:24:10 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-07 17:24:10 +0000
commite1e359ff59d6bbf09441cc1f3965be63f1046182 (patch)
treec7c05b27f535ebf52fe52fcea9e7fb0b07f18e28 /py/modsys.c
parent8785645a952c03315dbf93667b5f7c7eec49762f (diff)
py: Put mp_sys_path, mp_sys_argv and gc_collected in mp_state_ctx_t.
Without mp_sys_path and mp_sys_argv in the root pointer section of the state, their memory was being incorrectly collected by GC.
Diffstat (limited to 'py/modsys.c')
-rw-r--r--py/modsys.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/py/modsys.c b/py/modsys.c
index 51e10dae5..4ea60a697 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -24,6 +24,7 @@
* THE SOFTWARE.
*/
+#include "py/mpstate.h"
#include "py/nlr.h"
#include "py/builtin.h"
#include "py/objlist.h"
@@ -42,13 +43,6 @@ extern mp_uint_t mp_sys_stdin_obj;
extern mp_uint_t mp_sys_stdout_obj;
extern mp_uint_t mp_sys_stderr_obj;
-// These two lists must be initialised per port (after the call to mp_init).
-// TODO document these properly, they aren't constants or functions...
-/// \constant path - a mutable list of directories to search for imported modules
-mp_obj_list_t mp_sys_path_obj;
-/// \constant argv - a mutable list of arguments this program started with
-mp_obj_list_t mp_sys_argv_obj;
-
/// \constant version - Python language version that this implementation conforms to, as a string
STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0");
@@ -99,8 +93,8 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_pri
STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_sys) },
- { MP_OBJ_NEW_QSTR(MP_QSTR_path), (mp_obj_t)&mp_sys_path_obj },
- { MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&mp_sys_argv_obj },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_path), (mp_obj_t)&MP_STATE_VM(mp_sys_path_obj) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&MP_STATE_VM(mp_sys_argv_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&version_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj },
#ifdef MICROPY_PY_SYS_PLATFORM