Skip to content

Commit 024c8da

Browse files
committed
Combine some "can't convert" messages
1 parent d0427cf commit 024c8da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

py/obj.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
264264
return mp_obj_int_get_checked(arg);
265265
} else {
266266
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
267-
mp_raise_TypeError(translate("can't convert to int"));
267+
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_int);
268268
} else {
269269
mp_raise_TypeError_varg(
270270
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_int);
@@ -327,7 +327,7 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) {
327327

328328
if (!mp_obj_get_float_maybe(arg, &val)) {
329329
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
330-
mp_raise_TypeError(translate("can't convert to float"));
330+
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_float);
331331
} else {
332332
mp_raise_TypeError_varg(
333333
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_float);
@@ -360,7 +360,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
360360
mp_obj_complex_get(arg, real, imag);
361361
} else {
362362
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
363-
mp_raise_TypeError(translate("can't convert to complex"));
363+
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_complex);
364364
} else {
365365
mp_raise_TypeError_varg(
366366
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_complex);

0 commit comments

Comments
 (0)