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:
Philip Peitsch 2020-06-09 12:34:58 +10:00 committed by Damien George
parent a322ebafc0
commit edc92d18db
1 changed files with 1 additions and 0 deletions

View File

@ -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;
}