Commit 599bbc11 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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.
parent 5b65f0c7
......@@ -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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment