summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/modarray.c1
-rw-r--r--py/modbuiltins.c3
-rw-r--r--py/modcmath.c1
-rw-r--r--py/modcollections.c1
-rw-r--r--py/modgc.c1
-rw-r--r--py/modio.c1
-rw-r--r--py/modmath.c1
-rw-r--r--py/modmicropython.c1
-rw-r--r--py/modstruct.c1
-rw-r--r--py/modsys.c1
-rw-r--r--py/modthread.c1
-rw-r--r--py/moduerrno.c1
-rw-r--r--py/obj.h1
-rw-r--r--py/objmodule.c13
-rw-r--r--py/runtime.c1
15 files changed, 11 insertions, 18 deletions
diff --git a/py/modarray.c b/py/modarray.c
index cfee011e10..356e48bee0 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -37,7 +37,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_tab
const mp_obj_module_t mp_module_array = {
.base = { &mp_type_module },
- .name = MP_QSTR_array,
.globals = (mp_obj_dict_t*)&mp_module_array_globals,
};
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index ac3d3041f5..29f84d6c25 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -577,6 +577,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id);
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len);
STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) },
+
// built-in core functions
{ MP_ROM_QSTR(MP_QSTR___build_class__), MP_ROM_PTR(&mp_builtin___build_class___obj) },
{ MP_ROM_QSTR(MP_QSTR___import__), MP_ROM_PTR(&mp_builtin___import___obj) },
@@ -727,6 +729,5 @@ MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_tabl
const mp_obj_module_t mp_module_builtins = {
.base = { &mp_type_module },
- .name = MP_QSTR_builtins,
.globals = (mp_obj_dict_t*)&mp_module_builtins_globals,
};
diff --git a/py/modcmath.c b/py/modcmath.c
index 33fe9c73f5..7ad8f5ad60 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -160,7 +160,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_tab
const mp_obj_module_t mp_module_cmath = {
.base = { &mp_type_module },
- .name = MP_QSTR_cmath,
.globals = (mp_obj_dict_t*)&mp_module_cmath_globals,
};
diff --git a/py/modcollections.c b/py/modcollections.c
index dceaa203de..e610a28d24 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -40,7 +40,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections
const mp_obj_module_t mp_module_collections = {
.base = { &mp_type_module },
- .name = MP_QSTR_ucollections,
.globals = (mp_obj_dict_t*)&mp_module_collections_globals,
};
diff --git a/py/modgc.c b/py/modgc.c
index 976fb89980..24564622ec 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -119,7 +119,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
const mp_obj_module_t mp_module_gc = {
.base = { &mp_type_module },
- .name = MP_QSTR_gc,
.globals = (mp_obj_dict_t*)&mp_module_gc_globals,
};
diff --git a/py/modio.c b/py/modio.c
index f8826c71a7..2a38af602e 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -153,7 +153,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
const mp_obj_module_t mp_module_io = {
.base = { &mp_type_module },
- .name = MP_QSTR_uio,
.globals = (mp_obj_dict_t*)&mp_module_io_globals,
};
diff --git a/py/modmath.c b/py/modmath.c
index 54262f6115..0c70f34cd1 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -268,7 +268,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table
const mp_obj_module_t mp_module_math = {
.base = { &mp_type_module },
- .name = MP_QSTR_math,
.globals = (mp_obj_dict_t*)&mp_module_math_globals,
};
diff --git a/py/modmicropython.c b/py/modmicropython.c
index 805bda51d2..31ae7025fe 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -145,6 +145,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython
const mp_obj_module_t mp_module_micropython = {
.base = { &mp_type_module },
- .name = MP_QSTR_micropython,
.globals = (mp_obj_dict_t*)&mp_module_micropython_globals,
};
diff --git a/py/modstruct.c b/py/modstruct.c
index be0d0110de..5c07b8102a 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -265,7 +265,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_t
const mp_obj_module_t mp_module_ustruct = {
.base = { &mp_type_module },
- .name = MP_QSTR_ustruct,
.globals = (mp_obj_dict_t*)&mp_module_struct_globals,
};
diff --git a/py/modsys.c b/py/modsys.c
index 3bc5c2bafc..8c368ac35b 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -203,7 +203,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
const mp_obj_module_t mp_module_sys = {
.base = { &mp_type_module },
- .name = MP_QSTR_sys,
.globals = (mp_obj_dict_t*)&mp_module_sys_globals,
};
diff --git a/py/modthread.c b/py/modthread.c
index 6c8340c928..24b94f1c84 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -294,7 +294,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_t
const mp_obj_module_t mp_module_thread = {
.base = { &mp_type_module },
- .name = MP_QSTR__thread,
.globals = (mp_obj_dict_t*)&mp_module_thread_globals,
};
diff --git a/py/moduerrno.c b/py/moduerrno.c
index 343b29ba08..4a5e87419f 100644
--- a/py/moduerrno.c
+++ b/py/moduerrno.c
@@ -89,7 +89,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_t
const mp_obj_module_t mp_module_uerrno = {
.base = { &mp_type_module },
- .name = MP_QSTR_uerrno,
.globals = (mp_obj_dict_t*)&mp_module_uerrno_globals,
};
diff --git a/py/obj.h b/py/obj.h
index 22aa196fd1..72d79ce14b 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -765,7 +765,6 @@ MP_DECLARE_CONST_FUN_OBJ(mp_identity_obj);
// module
typedef struct _mp_obj_module_t {
mp_obj_base_t base;
- qstr name;
mp_obj_dict_t *globals;
} mp_obj_module_t;
mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in);
diff --git a/py/objmodule.c b/py/objmodule.c
index dc2ce787b4..9b06e3b7b5 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -37,17 +37,23 @@ STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
(void)kind;
mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
+ const char *module_name = "";
+ mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_MAP_LOOKUP);
+ if (elem != NULL) {
+ module_name = mp_obj_str_get_str(elem->value);
+ }
+
#if MICROPY_PY___FILE__
// If we store __file__ to imported modules then try to lookup this
// symbol to give more information about the module.
- mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP);
+ elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP);
if (elem != NULL) {
- mp_printf(print, "<module '%q' from '%s'>", self->name, mp_obj_str_get_str(elem->value));
+ mp_printf(print, "<module '%s' from '%s'>", module_name, mp_obj_str_get_str(elem->value));
return;
}
#endif
- mp_printf(print, "<module '%q'>", self->name);
+ mp_printf(print, "<module '%s'>", module_name);
}
STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
@@ -106,7 +112,6 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
// create new module object
mp_obj_module_t *o = m_new_obj(mp_obj_module_t);
o->base.type = &mp_type_module;
- o->name = module_name;
o->globals = MP_OBJ_TO_PTR(mp_obj_new_dict(MICROPY_MODULE_DICT_SIZE));
// store __name__ entry in the module
diff --git a/py/runtime.c b/py/runtime.c
index 48e815f0fa..c3e187d8a5 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -55,7 +55,6 @@
const mp_obj_module_t mp_module___main__ = {
.base = { &mp_type_module },
- .name = MP_QSTR___main__,
.globals = (mp_obj_dict_t*)&MP_STATE_VM(dict_main),
};