unify some 'must/should be an int' messages

This commit is contained in:
Jeff Epler 2022-06-23 08:25:20 -05:00
parent e045415f59
commit 267ec1dc4f
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
5 changed files with 10 additions and 55 deletions

View File

@ -2526,8 +2526,7 @@ msgstr ""
msgid "can't cancel self"
msgstr ""
#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c
#: shared-module/adafruit_pixelbuf/PixelBuf.c
#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c
msgid "can't convert %q to %q"
msgstr ""
@ -2714,10 +2713,6 @@ msgstr ""
msgid "color must be between 0x000000 and 0xffffff"
msgstr ""
#: shared-bindings/displayio/ColorConverter.c
msgid "color should be an int"
msgstr ""
#: py/emitnative.c
msgid "comparison of int and uint"
msgstr ""
@ -2869,10 +2864,6 @@ msgstr ""
msgid "end of format while looking for conversion specifier"
msgstr ""
#: shared-bindings/displayio/Shape.c
msgid "end_x should be an int"
msgstr ""
#: shared-bindings/alarm/time/TimeAlarm.c
msgid "epoch_time not supported on this board"
msgstr ""
@ -3739,10 +3730,6 @@ msgstr ""
msgid "palette must be 32 bytes long"
msgstr ""
#: shared-bindings/displayio/Palette.c
msgid "palette_index should be an int"
msgstr ""
#: py/emitinlinextensa.c
msgid "parameters must be registers in sequence a2 to a5"
msgstr ""
@ -3980,10 +3967,6 @@ msgstr ""
msgid "start/end indices"
msgstr ""
#: shared-bindings/displayio/Shape.c
msgid "start_x should be an int"
msgstr ""
#: shared-bindings/random/__init__.c
msgid "step must be non-zero"
msgstr ""
@ -4328,10 +4311,6 @@ msgstr ""
msgid "xTaskCreate failed"
msgstr ""
#: shared-bindings/displayio/Shape.c
msgid "y should be an int"
msgstr ""
#: shared-module/displayio/Shape.c
msgid "y value out of bounds"
msgstr ""

View File

@ -72,10 +72,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz
STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) {
displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t color;
if (!mp_obj_get_int_maybe(color_obj, &color)) {
mp_raise_ValueError(translate("color should be an int"));
}
mp_int_t color = mp_arg_validate_type_int(color_obj, MP_QSTR_color);
_displayio_colorspace_t colorspace;
colorspace.depth = 16;
uint32_t output_color;

View File

@ -156,11 +156,8 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t palette_index;
if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) {
mp_raise_ValueError(translate("palette_index should be an int"));
}
palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index);
mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index);
mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index);
common_hal_displayio_palette_make_transparent(self, palette_index);
return mp_const_none;
@ -173,10 +170,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_pale
STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t palette_index;
if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) {
mp_raise_ValueError(translate("palette_index should be an int"));
}
mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index);
palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index);
common_hal_displayio_palette_make_opaque(self, palette_index);
@ -191,10 +185,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_opaque_obj, displayio_palette_o
STATIC mp_obj_t displayio_palette_obj_is_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t palette_index;
if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) {
mp_raise_ValueError(translate("palette_index should be an int"));
}
mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index);
palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index);
return mp_obj_new_bool(common_hal_displayio_palette_is_transparent(self, palette_index));

View File

@ -80,18 +80,9 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg
STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) {
(void)n_args;
displayio_shape_t *self = MP_OBJ_TO_PTR(args[0]);
mp_int_t y;
if (!mp_obj_get_int_maybe(args[1], &y)) {
mp_raise_ValueError(translate("y should be an int"));
}
mp_int_t start_x;
if (!mp_obj_get_int_maybe(args[2], &start_x)) {
mp_raise_ValueError(translate("start_x should be an int"));
}
mp_int_t end_x;
if (!mp_obj_get_int_maybe(args[3], &end_x)) {
mp_raise_ValueError(translate("end_x should be an int"));
}
mp_int_t y = mp_arg_validate_type_int(args[1], MP_ARG_y);
mp_int_t start_x = mp_arg_validate_type_int(args[1], MP_ARG_start_x);
mp_int_t end_x = mp_arg_validate_type_int(args[1], MP_ARG_end_x);
common_hal_displayio_shape_set_boundary(self, y, start_x, end_x);
return mp_const_none;

View File

@ -85,10 +85,7 @@ STATIC mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t
uint8_t *addresses = NULL;
unsigned int i = 0;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
mp_int_t value;
if (!mp_obj_get_int_maybe(item, &value)) {
mp_raise_TypeError_varg(translate("can't convert %q to %q"), MP_QSTR_address, MP_QSTR_int);
}
mp_int_t value = mp_arg_validate_type_int(item, MP_QSTR_address);
if (value < 0x00 || value > 0x7f) {
mp_raise_ValueError(translate("address out of bounds"));
}