diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-18 04:11:19 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-18 04:20:17 +0300 |
commit | 599bbc111cbd83329e9418cefd1ed62ca2ed984c (patch) | |
tree | 7a9a1ae1d2e197cf7e7f21dc9bc7e828d108dfd7 /py/runtime.c | |
parent | 5b65f0c7d386646229b6647332e7a09277872e4c (diff) | |
download | micropython-599bbc111cbd83329e9418cefd1ed62ca2ed984c.tar.gz micropython-599bbc111cbd83329e9418cefd1ed62ca2ed984c.zip |
py: from import * should not import symbols starting with underscore.
I skipped implementing this initially, but then it causes __name__
of current module be overwritten and relative imports fail.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c index 7830301c77..30db01cd53 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1060,10 +1060,14 @@ import_error: void mp_import_all(mp_obj_t module) { DEBUG_printf("import all %p\n", module); + // TODO: Support __all__ mp_map_t *map = mp_obj_dict_get_map(mp_obj_module_get_globals(module)); for (uint i = 0; i < map->alloc; i++) { if (MP_MAP_SLOT_IS_FILLED(map, i)) { - mp_store_name(MP_OBJ_QSTR_VALUE(map->table[i].key), map->table[i].value); + qstr name = MP_OBJ_QSTR_VALUE(map->table[i].key); + if (*qstr_str(name) != '_') { + mp_store_name(name, map->table[i].value); + } } } } |