diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 29752a442c..9df78ea449 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -188,10 +188,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destination, mp_obj_t destination_length) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); - if (!mp_obj_is_small_int(destination_length) || MP_OBJ_SMALL_INT_VALUE(destination_length) < 0) { - mp_raise_TypeError(translate("destination_length must be an int >= 0")); - } - uint32_t length = MP_OBJ_SMALL_INT_VALUE(destination_length); + uint32_t length = mp_arg_validate_type_int(destination_length, MP_QSTR_length); + mp_arg_validate_length_min(length, 0, MP_QSTR_length); mp_buffer_info_t bufinfo; if (mp_obj_is_type(destination, &mp_type_fileio)) { diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index f955cd2afe..cce4f54e9d 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -34,9 +34,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t radius = args[ARG_radius].u_int; - if (radius < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_radius); - } + mp_arg_validate_int_min(radius, 1, MP_QSTR_radius); vectorio_circle_t *self = m_new_obj(vectorio_circle_t); self->base.type = &vectorio_circle_type; diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 34b9e1eabe..13c68161b3 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -34,13 +34,9 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_ mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t width = args[ARG_width].u_int; - if (width < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_width); - } + mp_arg_validate_int_min(width, 1, MP_QSTR_width); mp_int_t height = args[ARG_height].u_int; - if (height < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_height); - } + mp_arg_validate_int_min(height, 1, MP_QSTR_height); vectorio_rectangle_t *self = m_new_obj(vectorio_rectangle_t); self->base.type = &vectorio_rectangle_type;