summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorPhilip Peitsch <philip.peitsch@gmail.com>2020-06-09 12:34:58 +1000
committerDamien George <damien@micropython.org>2023-01-13 14:21:32 +1100
commitedc92d18db3e80c95ee565075fbe81f5b79d7df1 (patch)
tree01cdfe8804fd655ee64db8bb05717483bd0a3802 /py
parenta322ebafc0427f03e1423cf7642b1e6ded5a90a8 (diff)
py/map: Clear value when re-using slot with ordered dictionaries.
To adhere to the contract of mp_map_lookup, namely: MP_MAP_LOOKUP_ADD_IF_NOT_FOUND behaviour: - returns slot, with key non-null and value=MP_OBJ_NULL if it was added
Diffstat (limited to 'py')
-rw-r--r--py/map.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/map.c b/py/map.c
index 7a6f2233e..c18df5a9f 100644
--- a/py/map.c
+++ b/py/map.c
@@ -221,6 +221,7 @@ mp_map_elem_t *MICROPY_WRAP_MP_MAP_LOOKUP(mp_map_lookup)(mp_map_t * map, mp_obj_
}
mp_map_elem_t *elem = map->table + map->used++;
elem->key = index;
+ elem->value = MP_OBJ_NULL;
if (!mp_obj_is_qstr(index)) {
map->all_keys_are_qstrs = 0;
}