diff --git a/extmod/moductypes.c b/extmod/moductypes.c index a384f1e2c2..dc8ac4c721 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -520,7 +520,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_ob uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS); arr_sz &= VALUE_MASK(VAL_TYPE_BITS); if (index >= arr_sz) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("struct: index out of range"))); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_struct); } if (t->len == 2) { diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c index be8165a5aa..81ccc4fecf 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -330,7 +330,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, } if (index < 0 || index >= self->len) { common_hal_mcu_enable_interrupts(); - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; common_hal_mcu_enable_interrupts(); diff --git a/ports/cxd56/common-hal/pulseio/PulseIn.c b/ports/cxd56/common-hal/pulseio/PulseIn.c index 045acc9d2c..e54b5083db 100644 --- a/ports/cxd56/common-hal/pulseio/PulseIn.c +++ b/ports/cxd56/common-hal/pulseio/PulseIn.c @@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ } if (index < 0 || index >= self->len) { common_hal_mcu_enable_interrupts(); - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; common_hal_mcu_enable_interrupts(); diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c index e89a49e808..f5757ab788 100644 --- a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c +++ b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c @@ -237,7 +237,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, // } // if (index < 0 || index >= self->len) { // common_hal_mcu_enable_interrupts(); -// mp_raise_IndexError(translate("index out of range")); +// mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn); // } // uint16_t value = self->buffer[(self->start + index) % self->maxlen]; // common_hal_mcu_enable_interrupts(); diff --git a/ports/nrf/common-hal/pulseio/PulseIn.c b/ports/nrf/common-hal/pulseio/PulseIn.c index 80ff2c5291..c5de3a4b43 100644 --- a/ports/nrf/common-hal/pulseio/PulseIn.c +++ b/ports/nrf/common-hal/pulseio/PulseIn.c @@ -271,7 +271,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_ if ( !self->paused ) { nrfx_gpiote_in_event_enable(self->pin, true); } - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index b43fdd5547..a667cf0102 100644 --- a/ports/stm/common-hal/pulseio/PulseIn.c +++ b/ports/stm/common-hal/pulseio/PulseIn.c @@ -249,7 +249,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_ } if (index < 0 || index >= self->len) { HAL_NVIC_EnableIRQ(self->irq); - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; HAL_NVIC_EnableIRQ(self->irq); diff --git a/py/objstr.c b/py/objstr.c index 572bf299d4..edb562df27 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1076,7 +1076,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } field_name = str_to_int(field_name, field_name_top, &index); if ((uint)index >= n_args - 1) { - mp_raise_IndexError(translate("tuple index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple); } arg = args[index + 1]; *arg_i = -1; @@ -1104,7 +1104,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } } if ((uint)*arg_i >= n_args - 1) { - mp_raise_IndexError(translate("tuple index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple); } arg = args[(*arg_i) + 1]; (*arg_i)++; diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 19d89a31ce..50250abfa9 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -162,7 +162,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s if (is_slice) { return self_data; } - mp_raise_IndexError(translate("string index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str); } if (!UTF8_IS_CONT(*s)) { ++i; @@ -181,7 +181,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s if (is_slice) { return top; } - mp_raise_IndexError(translate("string index out of range")); + mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str); } // Then check completion if (i-- == 0) {