summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-03-18 17:26:19 +1100
committerDamien George <damien.p.george@gmail.com>2020-03-18 17:26:19 +1100
commitad9a0ec8abc9d04b93b949831b7152f55ca0d7ac (patch)
treef988445bbb8f1ef36b1ae69bfa6e60f4ed5d3d4e
parent8f0778b2092a4af1b7109b997a3c9c14766e31e8 (diff)
all: Convert exceptions to use mp_raise_XXX helpers in remaining places.
-rw-r--r--extmod/vfs_posix_file.c2
-rw-r--r--ports/esp32/modesp32.c4
-rw-r--r--ports/esp32/network_ppp.c2
-rw-r--r--ports/nrf/boards/microbit/modules/microbitimage.c10
-rw-r--r--py/modbuiltins.c2
-rw-r--r--py/modmath.c4
6 files changed, 12 insertions, 12 deletions
diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c
index 1a5c0eb0a..b49251f03 100644
--- a/extmod/vfs_posix_file.c
+++ b/extmod/vfs_posix_file.c
@@ -45,7 +45,7 @@ typedef struct _mp_obj_vfs_posix_file_t {
#ifdef MICROPY_CPYTHON_COMPAT
STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
if (o->fd < 0) {
- mp_raise_msg(&mp_type_ValueError, "I/O operation on closed file");
+ mp_raise_ValueError("I/O operation on closed file");
}
}
#else
diff --git a/ports/esp32/modesp32.c b/ports/esp32/modesp32.c
index e6d9f8045..0e0a7b7db 100644
--- a/ports/esp32/modesp32.c
+++ b/ports/esp32/modesp32.c
@@ -74,7 +74,7 @@ STATIC mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_m
gpio_num_t pin_id = machine_pin_get_id(args[ARG_pin].u_obj);
if (pin_id != machine_rtc_config.ext0_pin) {
if (!RTC_IS_VALID_EXT_PIN(pin_id)) {
- mp_raise_msg(&mp_type_ValueError, "invalid pin");
+ mp_raise_ValueError("invalid pin");
}
machine_rtc_config.ext0_pin = pin_id;
}
@@ -109,7 +109,7 @@ STATIC mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_m
gpio_num_t pin_id = machine_pin_get_id(elem[i]);
if (!RTC_IS_VALID_EXT_PIN(pin_id)) {
- mp_raise_msg(&mp_type_ValueError, "invalid pin");
+ mp_raise_ValueError("invalid pin");
break;
}
ext1_pins |= (1ll << pin_id);
diff --git a/ports/esp32/network_ppp.c b/ports/esp32/network_ppp.c
index 506c689ae..c522914ca 100644
--- a/ports/esp32/network_ppp.c
+++ b/ports/esp32/network_ppp.c
@@ -191,7 +191,7 @@ STATIC mp_obj_t ppp_connect_py(size_t n_args, const mp_obj_t *args, mp_map_t *kw
case PPPAUTHTYPE_CHAP:
break;
default:
- mp_raise_msg(&mp_type_ValueError, "invalid auth");
+ mp_raise_ValueError("invalid auth");
}
if (parsed_args[ARG_authmode].u_int != PPPAUTHTYPE_NONE) {
diff --git a/ports/nrf/boards/microbit/modules/microbitimage.c b/ports/nrf/boards/microbit/modules/microbitimage.c
index ce4a959f0..cc4719a3d 100644
--- a/ports/nrf/boards/microbit/modules/microbitimage.c
+++ b/ports/nrf/boards/microbit/modules/microbitimage.c
@@ -227,7 +227,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
return image_from_parsed_str(str, len);
}
} else {
- mp_raise_msg(&mp_type_TypeError, "Image(s) takes a string.");
+ mp_raise_TypeError("Image(s) takes a string.");
}
}
@@ -258,7 +258,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
}
default: {
- mp_raise_msg(&mp_type_TypeError, "Image() takes 0 to 3 arguments");
+ mp_raise_TypeError("Image() takes 0 to 3 arguments");
}
}
}
@@ -363,7 +363,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(microbit_image_get_pixel_obj, microbit_image_get_pixel
/* Raise an exception if not mutable */
static void check_mutability(microbit_image_obj_t *self) {
if (self->base.five) {
- mp_raise_msg(&mp_type_TypeError, "image cannot be modified (try copying first)");
+ mp_raise_TypeError("image cannot be modified (try copying first)");
}
}
@@ -406,10 +406,10 @@ mp_obj_t microbit_image_blit(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_t src = args[1];
if (mp_obj_get_type(src) != &microbit_image_type) {
- mp_raise_msg(&mp_type_TypeError, "expecting an image");
+ mp_raise_TypeError("expecting an image");
}
if (n_args == 7) {
- mp_raise_msg(&mp_type_TypeError, "must specify both offsets");
+ mp_raise_TypeError("must specify both offsets");
}
mp_int_t x = mp_obj_get_int(args[2]);
mp_int_t y = mp_obj_get_int(args[3]);
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 299ec2da7..f789cbaee 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -387,7 +387,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
default:
#if !MICROPY_PY_BUILTINS_POW3
- mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported");
+ mp_raise_NotImplementedError("3-arg pow() not supported");
#elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ
return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]);
#else
diff --git a/py/modmath.c b/py/modmath.c
index 5fe8e498c..52ad0b000 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -294,7 +294,7 @@ STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
mp_int_t max = mp_obj_get_int(x_obj);
if (max < 0) {
- mp_raise_msg(&mp_type_ValueError, "negative factorial");
+ mp_raise_ValueError("negative factorial");
} else if (max == 0) {
return MP_OBJ_NEW_SMALL_INT(1);
}
@@ -308,7 +308,7 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
mp_int_t max = mp_obj_get_int(x_obj);
if (max < 0) {
- mp_raise_msg(&mp_type_ValueError, "negative factorial");
+ mp_raise_ValueError("negative factorial");
} else if (max <= 1) {
return MP_OBJ_NEW_SMALL_INT(1);
}