summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/builtinimport.c3
-rw-r--r--py/modbuiltins.c3
-rw-r--r--py/modmath.c4
-rw-r--r--py/obj.c3
-rw-r--r--py/objcomplex.c2
-rw-r--r--py/objint_longlong.c2
-rw-r--r--py/objstrunicode.c4
-rw-r--r--py/stream.c4
8 files changed, 11 insertions, 14 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 6994fc48f4..173e040afb 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -230,8 +230,7 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
#endif
// If we get here then the file was not frozen and we can't compile scripts.
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
- "script compilation not supported"));
+ mp_raise_msg(&mp_type_ImportError, "script compilation not supported");
}
STATIC void chop_component(const char *start, const char **end) {
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index fe8159953a..169714a6b6 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -398,8 +398,7 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
#endif
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "ord expects a character"));
+ mp_raise_TypeError("ord expects a character");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"ord() expected a character, but string of length %d found", (int)len));
diff --git a/py/modmath.c b/py/modmath.c
index ddab337d05..10713234c7 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -25,7 +25,7 @@
*/
#include "py/builtin.h"
-#include "py/nlr.h"
+#include "py/runtime.h"
#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH
@@ -41,7 +41,7 @@
/// working with floating-point numbers.
STATIC NORETURN void math_error(void) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "math domain error"));
+ mp_raise_ValueError("math domain error");
}
#define MATH_FUN_1(py_name, c_name) \
diff --git a/py/obj.c b/py/obj.c
index 493945a227..1238b7011a 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -460,8 +460,7 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
}
} else if (value == MP_OBJ_SENTINEL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
- "object is not subscriptable"));
+ mp_raise_TypeError("object is not subscriptable");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"'%s' object is not subscriptable", mp_obj_get_type_str(base)));
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 5f9183f0e7..e4fbed1e8d 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -196,7 +196,7 @@ mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t
}
case MP_BINARY_OP_FLOOR_DIVIDE:
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't do truncated division of a complex number"));
+ mp_raise_TypeError("can't do truncated division of a complex number");
case MP_BINARY_OP_TRUE_DIVIDE:
case MP_BINARY_OP_INPLACE_TRUE_DIVIDE:
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index f638a53202..eb80407bcb 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -247,7 +247,7 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) {
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
// TODO raise an exception if the unsigned long long won't fit
if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OverflowError, "ulonglong too large"));
+ mp_raise_msg(&mp_type_OverflowError, "ulonglong too large");
}
mp_obj_int_t *o = m_new_obj(mp_obj_int_t);
o->base.type = &mp_type_int;
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 9a6ce9b9a2..d534285865 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -142,7 +142,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return self_data;
}
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_IndexError, "string index out of range"));
+ mp_raise_msg(&mp_type_IndexError, "string index out of range");
}
if (!UTF8_IS_CONT(*s)) {
++i;
@@ -161,7 +161,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return top;
}
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_IndexError, "string index out of range"));
+ mp_raise_msg(&mp_type_IndexError, "string index out of range");
}
// Then check completion
if (i-- == 0) {
diff --git a/py/stream.c b/py/stream.c
index d3fc767bbd..0186099034 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -142,7 +142,7 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
while (more_bytes > 0) {
char *p = vstr_add_len(&vstr, more_bytes);
if (p == NULL) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "out of memory"));
+ mp_raise_msg(&mp_type_MemoryError, "out of memory");
}
int error;
mp_uint_t out_sz = mp_stream_read_exactly(args[0], p, more_bytes, &error);
@@ -381,7 +381,7 @@ STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args)
while (max_size == -1 || max_size-- != 0) {
char *p = vstr_add_len(&vstr, 1);
if (p == NULL) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "out of memory"));
+ mp_raise_msg(&mp_type_MemoryError, "out of memory");
}
int error;