summaryrefslogtreecommitdiffstatshomepage
path: root/py/objdict.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-11 09:13:30 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-11 09:13:30 +0100
commit686afc5c0aaf2bc5a8d2547b703ab3177e0ea569 (patch)
treeaf911b84d516a18014258f64f49b917427c026ca /py/objdict.c
parentbe019ce0636398d1cbdee007d5238160dce8eda7 (diff)
downloadmicropython-686afc5c0aaf2bc5a8d2547b703ab3177e0ea569.tar.gz
micropython-686afc5c0aaf2bc5a8d2547b703ab3177e0ea569.zip
py: Check that sequence has 2 elements for dict iterable constructor.
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/objdict.c b/py/objdict.c
index 4dffa53da9..963e188074 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -50,9 +50,11 @@ STATIC mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
mp_obj_t iterable = mp_getiter(args[0]);
mp_obj_t dict = mp_obj_new_dict(0);
// TODO: support arbitrary seq as a pair
- mp_obj_tuple_t *item;
+ mp_obj_t item;
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
- mp_obj_dict_store(dict, item->items[0], item->items[1]);
+ mp_obj_t *sub_items;
+ mp_obj_get_array_fixed_n(item, 2, &sub_items);
+ mp_obj_dict_store(dict, sub_items[0], sub_items[1]);
}
return dict;
}