Skip to content

Commit edc92d1

Browse files
peitschiedpgeorge
authored andcommitted
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
1 parent a322eba commit edc92d1

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎py/map.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ mp_map_elem_t *MICROPY_WRAP_MP_MAP_LOOKUP(mp_map_lookup)(mp_map_t * map, mp_obj_
221221
}
222222
mp_map_elem_t *elem = map->table + map->used++;
223223
elem->key = index;
224+
elem->value = MP_OBJ_NULL;
224225
if (!mp_obj_is_qstr(index)) {
225226
map->all_keys_are_qstrs = 0;
226227
}

0 commit comments

Comments
 (0)