Use a function to raise ZeroDivisionError, consistent string
This commit is contained in:
parent
2b01c139f5
commit
0e19fbb60f
|
@ -118,7 +118,7 @@ msgstr ""
|
|||
msgid "%q is %q"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
#: py/argcheck.c shared-bindings/usb_hid/Device.c
|
||||
msgid "%q length must be %d"
|
||||
msgstr ""
|
||||
|
||||
|
@ -130,14 +130,10 @@ msgstr ""
|
|||
msgid "%q length must be <= %d"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
#: py/argcheck.c shared-bindings/busio/I2C.c
|
||||
msgid "%q length must be >= %d"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/busio/I2C.c
|
||||
msgid "%q length must be >= 1"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must be %d"
|
||||
msgstr ""
|
||||
|
@ -163,14 +159,6 @@ msgstr ""
|
|||
msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must be a string"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must be an int"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c py/obj.c
|
||||
msgid "%q must be of type %q"
|
||||
msgstr ""
|
||||
|
@ -201,10 +189,6 @@ msgstr ""
|
|||
msgid "%q pin invalid"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/usb_hid/Device.c
|
||||
msgid "%q with a report ID of 0 must be of length 1"
|
||||
msgstr ""
|
||||
|
||||
#: py/bc.c py/objnamedtuple.c
|
||||
msgid "%q() takes %d positional arguments but %d were given"
|
||||
msgstr ""
|
||||
|
@ -511,10 +495,6 @@ msgstr ""
|
|||
msgid "Array values should be single bytes."
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
msgid "At most %d %q may be specified (not %d)"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/memorymonitor/AllocationAlarm.c
|
||||
#, c-format
|
||||
msgid "Attempt to allocate %d blocks"
|
||||
|
@ -1260,10 +1240,6 @@ msgstr ""
|
|||
msgid "Invalid multicast MAC address"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/busio/UART.c
|
||||
msgid "Invalid pins"
|
||||
msgstr ""
|
||||
|
||||
#: ports/espressif/common-hal/espidf/__init__.c ports/espressif/esp_error.c
|
||||
msgid "Invalid size"
|
||||
msgstr ""
|
||||
|
@ -1501,11 +1477,6 @@ msgstr ""
|
|||
msgid "No long integer support"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/__init__.c
|
||||
#, c-format
|
||||
msgid "No more than %d HID devices allowed"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "No network with that ssid"
|
||||
msgstr ""
|
||||
|
@ -2545,10 +2516,6 @@ msgstr ""
|
|||
msgid "buffer too small for requested bytes"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/adafruit_pixelbuf/PixelBuf.c
|
||||
msgid "byteorder is not a string"
|
||||
msgstr ""
|
||||
|
||||
#: py/objarray.c
|
||||
msgid "bytes length not a multiple of item size"
|
||||
msgstr ""
|
||||
|
@ -2590,14 +2557,10 @@ msgstr ""
|
|||
msgid "can't cancel self"
|
||||
msgstr ""
|
||||
|
||||
#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c
|
||||
#: py/obj.c py/objint.c py/runtime.c shared-module/adafruit_pixelbuf/PixelBuf.c
|
||||
msgid "can't convert %q to %q"
|
||||
msgstr ""
|
||||
|
||||
#: py/runtime.c
|
||||
msgid "can't convert %q to int"
|
||||
msgstr ""
|
||||
|
||||
#: py/obj.c
|
||||
#, c-format
|
||||
msgid "can't convert %s to complex"
|
||||
|
@ -2781,10 +2744,6 @@ msgstr ""
|
|||
msgid "comparison of int and uint"
|
||||
msgstr ""
|
||||
|
||||
#: py/objcomplex.c
|
||||
msgid "complex division by zero"
|
||||
msgstr ""
|
||||
|
||||
#: py/objfloat.c py/parsenum.c
|
||||
msgid "complex values not supported"
|
||||
msgstr ""
|
||||
|
@ -2887,12 +2846,7 @@ msgstr ""
|
|||
msgid "div/mod not implemented for uint"
|
||||
msgstr ""
|
||||
|
||||
#: py/objfloat.c py/objint_mpz.c
|
||||
msgid "divide by zero"
|
||||
msgstr ""
|
||||
|
||||
#: py/modmath.c py/objint_longlong.c py/runtime.c
|
||||
#: shared-bindings/math/__init__.c
|
||||
#: py/runtime.c shared-bindings/math/__init__.c
|
||||
msgid "division by zero"
|
||||
msgstr ""
|
||||
|
||||
|
@ -4043,10 +3997,6 @@ msgstr ""
|
|||
msgid "syntax error in uctypes descriptor"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/time/__init__.c
|
||||
msgid "time.struct_time() takes a 9-sequence"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c
|
||||
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
|
||||
#: ports/nrf/common-hal/watchdog/WatchDogTimer.c
|
||||
|
|
|
@ -254,7 +254,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
|
|||
if (base <= (mp_float_t)0.0) {
|
||||
math_error();
|
||||
} else if (base == (mp_float_t)1.0) {
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_flo
|
|||
case MP_BINARY_OP_INPLACE_TRUE_DIVIDE:
|
||||
if (rhs_imag == 0) {
|
||||
if (rhs_real == 0) {
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("complex division by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
lhs_real /= rhs_real;
|
||||
lhs_imag /= rhs_real;
|
||||
|
|
|
@ -266,7 +266,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
|
|||
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
|
||||
if (rhs_val == 0) {
|
||||
zero_division_error:
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("divide by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
// Python specs require that x == (x//y)*y + (x%y) so we must
|
||||
// call divmod to compute the correct floor division, which
|
||||
|
|
|
@ -236,7 +236,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
|||
}
|
||||
|
||||
zero_division:
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_new_int(mp_int_t value) {
|
||||
|
|
|
@ -244,7 +244,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
|||
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: {
|
||||
if (mpz_is_zero(zrhs)) {
|
||||
zero_division_error:
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("divide by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
mpz_t rem;
|
||||
mpz_init_zero(&rem);
|
||||
|
|
|
@ -631,7 +631,7 @@ unsupported_op:
|
|||
#endif
|
||||
|
||||
zero_division:
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero"));
|
||||
mp_raise_ZeroDivisionError();
|
||||
}
|
||||
|
||||
mp_obj_t mp_call_function_0(mp_obj_t fun) {
|
||||
|
@ -1765,3 +1765,7 @@ NORETURN void mp_raise_recursion_depth(void) {
|
|||
mp_raise_RuntimeError(MP_ERROR_TEXT("maximum recursion depth exceeded"));
|
||||
}
|
||||
#endif
|
||||
|
||||
NORETURN void mp_raise_ZeroDivisionError(void) {
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero"));
|
||||
}
|
||||
|
|
|
@ -226,6 +226,7 @@ NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
|
|||
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_recursion_depth(void);
|
||||
NORETURN void mp_raise_ZeroDivisionError(void);
|
||||
#endif
|
||||
|
||||
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
|
||||
|
|
Loading…
Reference in New Issue