diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-05 00:47:06 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-05 01:40:41 +0200 |
commit | e11b17c25ff23b5d6c5e74bc2a9bbd28bc8d2fde (patch) | |
tree | 81612a4d8e851f571f41ff560ecd2109e0525da7 /py/runtime.c | |
parent | 6e6b888e31f9a4c245f621ccd91d3fce5ac88463 (diff) |
Implement support for sys.path when loading modules.
sys.path is not initialized by rt_init(), that's left for platform-specific
startup code. (For example, bare metal port may have some hardcoded defaults,
and let user change sys.path directly; while port for OS with environment
feature can take path from environment). If it's not explicitly initialized,
modules will be imported only from a current directory.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c index c84a28e4c..6d3cbf85b 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -168,8 +168,14 @@ void rt_init(void) { #if MICROPY_CPYTHON_COMPAT // Precreate sys module, so "import sys" didn't throw exceptions. - mp_obj_new_module(MP_QSTR_sys); + mp_obj_t m_sys = mp_obj_new_module(MP_QSTR_sys); + // Avoid warning of unused var + (void)m_sys; #endif + // init sys.path + // for efficiency, left to platform-specific startup code + //sys_path = mp_obj_new_list(0, NULL); + //rt_store_attr(m_sys, MP_QSTR_path, sys_path); mp_module_micropython_init(); |