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
This commit is contained in:
parent
a322ebafc0
commit
edc92d18db
1
py/map.c
1
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++;
|
mp_map_elem_t *elem = map->table + map->used++;
|
||||||
elem->key = index;
|
elem->key = index;
|
||||||
|
elem->value = MP_OBJ_NULL;
|
||||||
if (!mp_obj_is_qstr(index)) {
|
if (!mp_obj_is_qstr(index)) {
|
||||||
map->all_keys_are_qstrs = 0;
|
map->all_keys_are_qstrs = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue