py/objset: Include the failed key in a KeyError raised from set.remove.
This commit is contained in:
parent
2ac1364688
commit
1394258f37
@ -380,7 +380,7 @@ STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
|
||||
check_set(self_in);
|
||||
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_KeyError));
|
||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, item));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ print(s.remove(1))
|
||||
print(list(s))
|
||||
try:
|
||||
print(s.remove(1), "!!!")
|
||||
except KeyError:
|
||||
pass
|
||||
except KeyError as er:
|
||||
print('KeyError', er.args[0])
|
||||
else:
|
||||
print("failed to raise KeyError")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user