summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/objlist.c6
-rw-r--r--py/qstrdefs.h2
-rw-r--r--py/runtime.c3
3 files changed, 8 insertions, 3 deletions
diff --git a/py/objlist.c b/py/objlist.c
index 59a4ad6b12..aa857e41c2 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -435,8 +435,10 @@ static mp_obj_list_t *list_new(uint n) {
mp_obj_t mp_obj_new_list(uint n, mp_obj_t *items) {
mp_obj_list_t *o = list_new(n);
- for (int i = 0; i < n; i++) {
- o->items[i] = items[i];
+ if (items != NULL) {
+ for (int i = 0; i < n; i++) {
+ o->items[i] = items[i];
+ }
}
return o;
}
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index b246c5b427..bf575e25d1 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -31,6 +31,7 @@ Q(StopIteration)
Q(AssertionError)
Q(AttributeError)
+Q(ImportError)
Q(IndentationError)
Q(IndexError)
Q(KeyError)
@@ -80,6 +81,7 @@ Q(set)
Q(sorted)
Q(sum)
Q(str)
+Q(sys)
Q(tuple)
Q(type)
Q(zip)
diff --git a/py/runtime.c b/py/runtime.c
index 74c55ea6cb..c84a28e4cb 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -92,6 +92,7 @@ void rt_init(void) {
// built-in exceptions (TODO, make these proper classes, and const if possible)
mp_map_add_qstr(&map_builtins, MP_QSTR_AttributeError, mp_obj_new_exception(MP_QSTR_AttributeError));
+ mp_map_add_qstr(&map_builtins, MP_QSTR_ImportError, mp_obj_new_exception(MP_QSTR_ImportError));
mp_map_add_qstr(&map_builtins, MP_QSTR_IndexError, mp_obj_new_exception(MP_QSTR_IndexError));
mp_map_add_qstr(&map_builtins, MP_QSTR_KeyError, mp_obj_new_exception(MP_QSTR_KeyError));
mp_map_add_qstr(&map_builtins, MP_QSTR_NameError, mp_obj_new_exception(MP_QSTR_NameError));
@@ -167,7 +168,7 @@ void rt_init(void) {
#if MICROPY_CPYTHON_COMPAT
// Precreate sys module, so "import sys" didn't throw exceptions.
- mp_obj_new_module(QSTR_FROM_STR_STATIC("sys"));
+ mp_obj_new_module(MP_QSTR_sys);
#endif
mp_module_micropython_init();