summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-16 10:56:39 -0800
committerDamien George <damien.p.george@gmail.com>2014-01-16 10:56:39 -0800
commiteea2eb1bb74c59e80deb14872a0aa10d6a69a304 (patch)
tree77c4ec4cbede304afffe0f7a86f8e9886e8b900d /py/runtime.c
parenta671f891ddb42496accb889e19a0eb14b50caba2 (diff)
parentdcac88095b3a67e75204f6b245d62d481ce2d906 (diff)
downloadmicropython-eea2eb1bb74c59e80deb14872a0aa10d6a69a304.tar.gz
micropython-eea2eb1bb74c59e80deb14872a0aa10d6a69a304.zip
Merge pull request #180 from pfalcon/examples-improve
Improve compatibility of examples with CPython (+ interp compatibility too)
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index e1e9e31cc7..0da3ced058 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -143,6 +143,13 @@ void rt_init(void) {
mp_map_add_qstr(&map_builtins, MP_QSTR_sum, (mp_obj_t)&mp_builtin_sum_obj);
mp_map_add_qstr(&map_builtins, MP_QSTR_str, (mp_obj_t)&mp_builtin_str_obj);
+#if MICROPY_CPYTHON_COMPAT
+ // Add (empty) micropython module, so it was possible to "import micropython",
+ // which can be a placeholder module on CPython.
+ mp_obj_t m = mp_obj_new_module(qstr_from_str_static("micropython"));
+ rt_store_name(qstr_from_str_static("micropython"), m);
+#endif
+
next_unique_code_id = 1; // 0 indicates "no code"
unique_codes_alloc = 0;
unique_codes = NULL;