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.
pull/512/head
Paul Sokolovsky 2014-04-18 04:11:19 +03:00
rodzic 5b65f0c7d3
commit 599bbc111c
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -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);
}
}
}
}