summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-03-30 11:09:00 +1100
committerDamien George <damien.p.george@gmail.com>2018-03-30 11:13:32 +1100
commit32807881954f106b9735de74fe984062a0815b81 (patch)
tree191a534e36c54c7c26005864045996fc87f6abb8 /py/runtime.c
parentbc3a5f191714f28bef95d9f87c24f7367c90d54a (diff)
py/runtime: Check that keys in dicts passed as ** args are strings.
Prior to this patch the code would crash if a key in a ** dict was anything other than a str or qstr. This is because mp_setup_code_state() assumes that keys in kwargs are qstrs (for efficiency). Thanks to @jepler for finding the bug.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 54ec0d70b..ca68fe982 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -748,8 +748,8 @@ void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
// the key must be a qstr, so intern it if it's a string
mp_obj_t key = map->table[i].key;
- if (MP_OBJ_IS_TYPE(key, &mp_type_str)) {
- key = mp_obj_str_intern(key);
+ if (!MP_OBJ_IS_QSTR(key)) {
+ key = mp_obj_str_intern_checked(key);
}
args2[args2_len++] = key;
args2[args2_len++] = map->table[i].value;
@@ -778,8 +778,8 @@ void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_
}
// the key must be a qstr, so intern it if it's a string
- if (MP_OBJ_IS_TYPE(key, &mp_type_str)) {
- key = mp_obj_str_intern(key);
+ if (!MP_OBJ_IS_QSTR(key)) {
+ key = mp_obj_str_intern_checked(key);
}
// get the value corresponding to the key