mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 21:20:13 +01:00
py: Add mp_raise_type helper macro and use it where appropriate.
This provides a more consistent C-level API to raise exceptions, ie moving away from nlr_raise towards mp_raise_XXX. It also reduces code size by a small amount on some ports.
This commit is contained in:
@@ -154,7 +154,7 @@ STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) {
|
||||
if (len > 0) {
|
||||
return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL);
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_IndexError));
|
||||
mp_raise_type(&mp_type_IndexError);
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_urandom_choice_obj, mod_urandom_choice);
|
||||
|
||||
Reference in New Issue
Block a user