extmod/modbtree: __getitem__() should raise KeyError for non-existing key.

This commit is contained in:
Paul Sokolovsky 2016-06-18 01:30:49 +03:00
parent cbffd0aadd
commit e9739e3315
1 changed files with 1 additions and 1 deletions

View File

@ -203,7 +203,7 @@ STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
key.data = (void*)mp_obj_str_get_data(index, &key.size);
int res = __bt_get(self->db, &key, &val, 0);
if (res == RET_SPECIAL) {
return mp_const_none;
nlr_raise(mp_obj_new_exception(&mp_type_KeyError));
}
CHECK_ERROR(res);
return mp_obj_new_bytes(val.data, val.size);