8000 py: Shorten error messages by using contractions and some rewording. · andrewleech/micropython@b01f66c · GitHub
[go: up one dir, main page]

Skip to content

Commit b01f66c

Browse files
committed
py: Shorten error messages by using contractions and some rewording.
1 parent 0a36a80 commit b01f66c

18 files changed

+36
-36
lines changed

py/argcheck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) {
4141
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
4242
mp_arg_error_terse_mismatch();
4343
} else {
44-
mp_raise_TypeError("function does not take keyword arguments");
44+
mp_raise_TypeError("function doesn't take keyword arguments");
4545
}
4646
}
4747

py/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2826,7 +2826,7 @@ STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
28262826
bool added;
28272827
id_info_t *id_info = scope_find_or_add_id(comp->scope_cur, param_name, &added);
28282828
if (!added) {
2829-
compile_syntax_error(comp, pn, "name reused for argument");
2829+
compile_syntax_error(comp, pn, "argument name reused");
28302830
return;
28312831
}
28322832
id_info->kind = ID_INFO_KIND_LOCAL;

py/emitinlinethumb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
301301
}
302302
uint32_t i = mp_obj_get_int_truncated(o);
303303
if ((i & (~fit_mask)) != 0) {
304-
emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x does not fit in mask 0x%x", op, i, fit_mask));
304+
emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer 0x%x doesn't fit in mask 0x%x", op, i, fit_mask));
305305
return 0;
306306
}
307307
return i;

py/emitinlinextensa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
171171
}
172172
uint32_t i = mp_obj_get_int_truncated(o);
173173
if (min != max && ((int)i < min || (int)i > max)) {
174-
emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d is not within range %d..%d", op, i, min, max));
174+
emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, "'%s' integer %d isn't within range %d..%d", op, i, min, max));
175175
return 0;
176176
}
177177
return i;

py/modmath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
187187
if (base <= (mp_float_t)0.0) {
188188
math_error();
189189
} else if (base == (mp_float_t)1.0) {
190-
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
190+
mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
191191
}
192192
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
193193
}

py/obj.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
353353
mp_raise_TypeError("expected tuple/list");
354354
} else {
355355
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
356-
"object '%s' is not a tuple or list", mp_obj_get_type_str(o)));
356+
"object '%s' isn't a tuple or list", mp_obj_get_type_str(o)));
357357
}
358358
}
359359
}
@@ -475,24 +475,24 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
475475
}
476476
if (value == MP_OBJ_NULL) {
477477
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
478-
mp_raise_TypeError("object does not support item deletion");
478+
mp_raise_TypeError("object doesn't support item deletion");
479479
} else {
480480
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
481-
"'%s' object does not support item deletion", mp_obj_get_type_str(base)));
481+
"'%s' object doesn't support item deletion", mp_obj_get_type_str(base)));
482482
}
483483
} else if (value == MP_OBJ_SENTINEL) {
484484
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
485-
mp_raise_TypeError("object is not subscriptable");
485+
mp_raise_TypeError("object isn't subscriptable");
486486
} else {
487487
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
488-
"'%s' object is not subscriptable", mp_obj_get_type_str(base)));
488+
"'%s' object isn't subscriptable", mp_obj_get_type_str(base)));
489489
}
490490
} else {
491491
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
492-
mp_raise_TypeError("object does not support item assignment");
492+
mp_raise_TypeError("object doesn't support item assignment");
493493
} else {
494494
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
495-
"'%s' object does not support item assignment", mp_obj_get_type_str(base)));
495+
"'%s' object doesn't support item assignment", mp_obj_get_type_str(base)));
496496
}
497497
}
498498
}

py/objcomplex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_flo
195195
}
196196
case MP_BINARY_OP_FLOOR_DIVIDE:
197197
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
198-
mp_raise_TypeError("can't do truncated division of a complex number");
198+
mp_raise_TypeError("can't truncate-divide a complex number");
199199

200200
case MP_BINARY_OP_TRUE_DIVIDE:
201201
case MP_BINARY_OP_INPLACE_TRUE_DIVIDE:
202202
if (rhs_imag == 0) {
203203
if (rhs_real == 0) {
204-
mp_raise_msg(&mp_type_ZeroDivisionError, "complex division by zero");
204+
mp_raise_msg(&mp_type_ZeroDivisionError, "complex divide by zero");
205205
}
206206
lhs_real /= rhs_real;
207207
lhs_imag /= rhs_real;

py/objfloat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
262262
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
263263
if (rhs_val == 0) {
264264
zero_division_error:
265-
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
265+
mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
266266
}
267267
// Python specs require that x == (x//y)*y + (x%y) so we must
268268
// call divmod to compute the correct floor division, which

py/objint_longlong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
217217
}
218218

219219
zero_division:
220-
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
220+
mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
221221
}
222222

223223
mp_obj_t mp_obj_new_int(mp_int_t value) {

py/objint_mpz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
225225
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: {
226226
if (mpz_is_zero(zrhs)) {
227227
zero_division_error:
228-
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
228+
mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
229229
}
230230
mpz_t rem; mpz_init_zero(&rem);
231231
mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs);

0 commit comments

Comments
 (0)
0