Skip to content

Commit 549632a

Browse files
committed
Combine 'index out of range' messages
1 parent 67c8173 commit 549632a

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

extmod/moductypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_ob
520520
uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS);
521521
arr_sz &= VALUE_MASK(VAL_TYPE_BITS);
522522
if (index >= arr_sz) {
523-
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("struct: index out of range")));
523+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_struct);
524524
}
525525

526526
if (t->len == 2) {

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self,
330330
}
331331
if (index < 0 || index >= self->len) {
332332
common_hal_mcu_enable_interrupts();
333-
mp_raise_IndexError(translate("index out of range"));
333+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
334334
}
335335
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
336336
common_hal_mcu_enable_interrupts();

ports/cxd56/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
190190
}
191191
if (index < 0 || index >= self->len) {
192192
common_hal_mcu_enable_interrupts();
193-
mp_raise_IndexError(translate("index out of range"));
193+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
194194
}
195195
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
196196
common_hal_mcu_enable_interrupts();

ports/mimxrt10xx/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self,
237237
// }
238238
// if (index < 0 || index >= self->len) {
239239
// common_hal_mcu_enable_interrupts();
240-
// mp_raise_IndexError(translate("index out of range"));
240+
// mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
241241
// }
242242
// uint16_t value = self->buffer[(self->start + index) % self->maxlen];
243243
// common_hal_mcu_enable_interrupts();

ports/nrf/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
271271
if ( !self->paused ) {
272272
nrfx_gpiote_in_event_enable(self->pin, true);
273273
}
274-
mp_raise_IndexError(translate("index out of range"));
274+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
275275
}
276276
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
277277

ports/stm/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
249249
}
250250
if (index < 0 || index >= self->len) {
251251
HAL_NVIC_EnableIRQ(self->irq);
252-
mp_raise_IndexError(translate("index out of range"));
252+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
253253
}
254254
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
255255
HAL_NVIC_EnableIRQ(self->irq);

py/objstr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
10761076
}
10771077
field_name = str_to_int(field_name, field_name_top, &index);
10781078
if ((uint)index >= n_args - 1) {
1079-
mp_raise_IndexError(translate("tuple index out of range"));
1079+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple);
10801080
}
10811081
arg = args[index + 1];
10821082
*arg_i = -1;
@@ -1104,7 +1104,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
11041104
}
11051105
}
11061106
if ((uint)*arg_i >= n_args - 1) {
1107-
mp_raise_IndexError(translate("tuple index out of range"));
1107+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple);
11081108
}
11091109
arg = args[(*arg_i) + 1];
11101110
(*arg_i)++;

py/objstrunicode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
162162
if (is_slice) {
163163
return self_data;
164164
}
165-
mp_raise_IndexError(translate("string index out of range"));
165+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str);
166166
}
167167
if (!UTF8_IS_CONT(*s)) {
168168
++i;
@@ -181,7 +181,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
181181
if (is_slice) {
182182
return top;
183183
}
184-
mp_raise_IndexError(translate("string index out of range"));
184+
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str);
185185
}
186186
// Then check completion
187187
if (i-- == 0) {

0 commit comments

Comments
 (0)