Commit 1394258f authored by Damien George's avatar Damien George

py/objset: Include the failed key in a KeyError raised from set.remove.

parent 2ac13646
......@@ -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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment