summaryrefslogtreecommitdiffstatshomepage
path: root/py/objmodule.c
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-07 23:06:46 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-07 23:06:46 +0000
commit9c83ec0edac2394431a5d1aecba1d666ffdea0a3 (patch)
treeccf18860da373cf13194788b793a962335d69fef /py/objmodule.c
parent27d4ca7693c276d09a911c00c3442729c516dc23 (diff)
downloadmicropython-9c83ec0edac2394431a5d1aecba1d666ffdea0a3.tar.gz
micropython-9c83ec0edac2394431a5d1aecba1d666ffdea0a3.zip
Merge remote-tracking branch 'upstream/master' into dict_feats
Diffstat (limited to 'py/objmodule.c')
-rw-r--r--py/objmodule.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/py/objmodule.c b/py/objmodule.c
index 2d6f9555e8..7b92b76f42 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -6,6 +6,7 @@
#include "nlr.h"
#include "misc.h"
#include "mpconfig.h"
+#include "mpqstr.h"
#include "obj.h"
#include "runtime.h"
#include "map.h"
@@ -24,21 +25,15 @@ void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_
const mp_obj_type_t module_type = {
{ &mp_const_type },
"module",
- module_print, // print
- NULL, // make_new
- NULL, // call_n
- NULL, // unary_op
- NULL, // binary_op
- NULL, // getiter
- NULL, // iternext
- .methods = {{NULL, NULL},},
+ .print = module_print,
};
mp_obj_t mp_obj_new_module(qstr module_name) {
mp_obj_module_t *o = m_new_obj(mp_obj_module_t);
o->base.type = &module_type;
o->name = module_name;
- o->globals = mp_map_new(MP_MAP_QSTR, 0);
+ o->globals = mp_map_new(MP_MAP_QSTR, 1);
+ mp_qstr_map_lookup(o->globals, MP_QSTR___name__, true)->value = mp_obj_new_str(module_name);
return o;
}