diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-02-14 07:42:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-14 07:42:39 -0500 |
| commit | 379258112aad44255ef3acaada0749c556b7b09e (patch) | |
| tree | b5e53b0403c11ede4f3bb744e6e5d0fec4d0ccef | |
| parent | f99b9ddcf1ccbdeb32ed01d1c3ef0aaeeef3a5b7 (diff) | |
| parent | b13adfc228016856eeb1c77ecf1f500755cb2a55 (diff) | |
Merge pull request #1548 from tannewt/shape_arg_check
Arg check width and height into Shape.
| -rw-r--r-- | shared-bindings/bleio/CharacteristicBuffer.c | 2 | ||||
| -rw-r--r-- | shared-bindings/displayio/Shape.c | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/shared-bindings/bleio/CharacteristicBuffer.c b/shared-bindings/bleio/CharacteristicBuffer.c index 32629ca19..66d164954 100644 --- a/shared-bindings/bleio/CharacteristicBuffer.c +++ b/shared-bindings/bleio/CharacteristicBuffer.c @@ -76,7 +76,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, const int buffer_size = args[ARG_buffer_size].u_int; if (buffer_size < 1) { - mp_raise_ValueError(translate("buffer_size must be >= 1")); + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size); } if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) { diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 6824b1fef..faa9472fa 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -64,11 +64,20 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_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_int_t height = args[ARG_height].u_int; + if (height < 1) { + mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_height); + } + displayio_shape_t *self = m_new_obj(displayio_shape_t); self->base.type = &displayio_shape_type; common_hal_displayio_shape_construct(self, - args[ARG_width].u_int, - args[ARG_height].u_int, + width, + height, args[ARG_mirror_x].u_bool, args[ARG_mirror_y].u_bool); |
