summaryrefslogtreecommitdiff
path: root/extmod
diff options
context:
space:
mode:
Diffstat (limited to 'extmod')
-rw-r--r--extmod/machine_i2c.c12
-rw-r--r--extmod/machine_spi.c12
-rw-r--r--extmod/moductypes.c12
-rw-r--r--extmod/moduhashlib.c4
-rw-r--r--extmod/moduheapq.c6
-rw-r--r--extmod/modujson.c4
-rw-r--r--extmod/modussl_axtls.c6
-rw-r--r--extmod/modutimeq.c8
-rw-r--r--extmod/moduzlib.c4
-rw-r--r--extmod/uos_dupterm.c4
10 files changed, 46 insertions, 26 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c
index 5d441b1ba..b91f1a1eb 100644
--- a/extmod/machine_i2c.c
+++ b/extmod/machine_i2c.c
@@ -33,6 +33,8 @@
#include "py/runtime.h"
#include "extmod/machine_i2c.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_MACHINE_I2C
typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t;
@@ -294,7 +296,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
#else
- mp_raise_ValueError("invalid I2C peripheral");
+ mp_raise_ValueError(translate("invalid I2C peripheral"));
#endif
}
--n_args;
@@ -335,7 +337,7 @@ STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->start == NULL) {
- mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
+ mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
}
int ret = i2c_p->start(self);
if (ret != 0) {
@@ -349,7 +351,7 @@ STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->stop == NULL) {
- mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
+ mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
}
int ret = i2c_p->stop(self);
if (ret != 0) {
@@ -363,7 +365,7 @@ STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->read == NULL) {
- mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
+ mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
}
// get the buffer to read into
@@ -387,7 +389,7 @@ STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->write == NULL) {
- mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
+ mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
}
// get the buffer to write from
diff --git a/extmod/machine_spi.c b/extmod/machine_spi.c
index f0c4896c2..3bbab2824 100644
--- a/extmod/machine_spi.c
+++ b/extmod/machine_spi.c
@@ -30,6 +30,8 @@
#include "py/runtime.h"
#include "extmod/machine_spi.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_MACHINE_SPI
// if a port didn't define MSB/LSB constants then provide them
@@ -52,7 +54,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
#else
- mp_raise_ValueError("invalid SPI peripheral");
+ mp_raise_ValueError(translate("invalid SPI peripheral"));
#endif
}
--n_args;
@@ -119,7 +121,7 @@ STATIC mp_obj_t mp_machine_spi_write_readinto(mp_obj_t self, mp_obj_t wr_buf, mp
mp_buffer_info_t dest;
mp_get_buffer_raise(rd_buf, &dest, MP_BUFFER_WRITE);
if (src.len != dest.len) {
- mp_raise_ValueError("buffers must be the same length");
+ mp_raise_ValueError(translate("buffers must be the same length"));
}
mp_machine_spi_transfer(self, src.len, src.buf, dest.buf);
return mp_const_none;
@@ -202,15 +204,15 @@ STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n
self->spi.polarity = args[ARG_polarity].u_int;
self->spi.phase = args[ARG_phase].u_int;
if (args[ARG_bits].u_int != 8) {
- mp_raise_ValueError("bits must be 8");
+ mp_raise_ValueError(translate("bits must be 8"));
}
if (args[ARG_firstbit].u_int != MICROPY_PY_MACHINE_SPI_MSB) {
- mp_raise_ValueError("firstbit must be MSB");
+ mp_raise_ValueError(translate("firstbit must be MSB"));
}
if (args[ARG_sck].u_obj == MP_OBJ_NULL
|| args[ARG_mosi].u_obj == MP_OBJ_NULL
|| args[ARG_miso].u_obj == MP_OBJ_NULL) {
- mp_raise_ValueError("must specify all of sck/mosi/miso");
+ mp_raise_ValueError(translate("must specify all of sck/mosi/miso"));
}
self->spi.sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj);
self->spi.mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj);
diff --git a/extmod/moductypes.c b/extmod/moductypes.c
index b0f28331e..e627cd146 100644
--- a/extmod/moductypes.c
+++ b/extmod/moductypes.c
@@ -32,6 +32,8 @@
#include "py/objtuple.h"
#include "py/binary.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UCTYPES
/// \module uctypes - Access data structures in memory
@@ -117,7 +119,7 @@ typedef struct _mp_obj_uctypes_struct_t {
} mp_obj_uctypes_struct_t;
STATIC NORETURN void syntax_error(void) {
- mp_raise_TypeError("syntax error in uctypes descriptor");
+ mp_raise_TypeError(translate("syntax error in uctypes descriptor"));
}
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -214,7 +216,7 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_
// but scalar structure field is lowered into native Python int, so all
// type info is lost. So, we cannot say if it's scalar type description,
// or such lowered scalar.
- mp_raise_TypeError("Cannot unambiguously get sizeof scalar");
+ mp_raise_TypeError(translate("Cannot unambiguously get sizeof scalar"));
}
syntax_error();
}
@@ -392,7 +394,7 @@ STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_obj_t set
// TODO: Support at least OrderedDict in addition
if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) {
- mp_raise_TypeError("struct: no fields");
+ mp_raise_TypeError(translate("struct: no fields"));
}
mp_obj_t deref = mp_obj_dict_get(self->desc, MP_OBJ_NEW_QSTR(attr));
@@ -525,7 +527,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
} else {
// load / store
if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) {
- mp_raise_TypeError("struct: cannot index");
+ mp_raise_TypeError(translate("struct: cannot index"));
}
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc);
@@ -539,7 +541,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS);
arr_sz &= VALUE_MASK(VAL_TYPE_BITS);
if (index >= arr_sz) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "struct: index out of range"));
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("struct: index out of range")));
}
if (t->len == 2) {
diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c
index 5e14fc8d4..1618594e9 100644
--- a/extmod/moduhashlib.c
+++ b/extmod/moduhashlib.c
@@ -29,6 +29,8 @@
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UHASHLIB
#if MICROPY_PY_UHASHLIB_SHA256
@@ -97,7 +99,7 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
static void check_not_unicode(const mp_obj_t arg) {
#if MICROPY_CPYTHON_COMPAT
if (MP_OBJ_IS_STR(arg)) {
- mp_raise_TypeError("a bytes-like object is required");
+ mp_raise_TypeError(translate("a bytes-like object is required"));
}
#endif
}
diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c
index 71c15368b..db17e8ca2 100644
--- a/extmod/moduheapq.c
+++ b/extmod/moduheapq.c
@@ -27,13 +27,15 @@
#include "py/objlist.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UHEAPQ
// the algorithm here is modelled on CPython's heapq.py
STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) {
if (!MP_OBJ_IS_TYPE(heap_in, &mp_type_list)) {
- mp_raise_TypeError("heap must be a list");
+ mp_raise_TypeError(translate("heap must be a list"));
}
return MP_OBJ_TO_PTR(heap_in);
}
@@ -81,7 +83,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
mp_obj_list_t *heap = get_heap(heap_in);
if (heap->len == 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("empty heap")));
}
mp_obj_t item = heap->items[0];
heap->len -= 1;
diff --git a/extmod/modujson.c b/extmod/modujson.c
index 830b588fd..ea6c8b40f 100644
--- a/extmod/modujson.c
+++ b/extmod/modujson.c
@@ -32,6 +32,8 @@
#include "py/runtime.h"
#include "py/stream.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UJSON
STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) {
@@ -276,7 +278,7 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
return stack_top;
fail:
- mp_raise_ValueError("syntax error in JSON");
+ mp_raise_ValueError(translate("syntax error in JSON"));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load);
diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c
index 475d3f0ea..cfa652585 100644
--- a/extmod/modussl_axtls.c
+++ b/extmod/modussl_axtls.c
@@ -30,6 +30,8 @@
#include "py/runtime.h"
#include "py/stream.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_USSL && MICROPY_SSL_AXTLS
#include "ssl.h"
@@ -76,13 +78,13 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
const byte *data = (const byte*)mp_obj_str_get_data(args->key.u_obj, &len);
int res = ssl_obj_memory_load(o->ssl_ctx, SSL_OBJ_RSA_KEY, data, len, NULL);
if (res != SSL_OK) {
- mp_raise_ValueError("invalid key");
+ mp_raise_ValueError(translate("invalid key"));
}
data = (const byte*)mp_obj_str_get_data(args->cert.u_obj, &len);
res = ssl_obj_memory_load(o->ssl_ctx, SSL_OBJ_X509_CERT, data, len, NULL);
if (res != SSL_OK) {
- mp_raise_ValueError("invalid cert");
+ mp_raise_ValueError(translate("invalid cert"));
}
}
diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c
index 28bbcc521..614820443 100644
--- a/extmod/modutimeq.c
+++ b/extmod/modutimeq.c
@@ -31,6 +31,8 @@
#include "py/runtime.h"
#include "py/smallint.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UTIMEQ
#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD
@@ -126,7 +128,7 @@ STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
mp_obj_t heap_in = args[0];
mp_obj_utimeq_t *heap = get_heap(heap_in);
if (heap->len == heap->alloc) {
- mp_raise_IndexError("queue overflow");
+ mp_raise_IndexError(translate("queue overflow"));
}
mp_uint_t l = heap->len;
heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]);
@@ -142,7 +144,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_ut
STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
mp_obj_utimeq_t *heap = get_heap(heap_in);
if (heap->len == 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
+ mp_raise_IndexError(translate("empty heap"));
}
mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref);
if (!MP_OBJ_IS_TYPE(list_ref, &mp_type_list) || ret->len < 3) {
@@ -167,7 +169,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop);
STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
mp_obj_utimeq_t *heap = get_heap(heap_in);
if (heap->len == 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
+ mp_raise_IndexError(translate("empty heap"));
}
struct qentry *item = &heap->items[0];
diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c
index 0d2366bea..f70ecd92c 100644
--- a/extmod/moduzlib.c
+++ b/extmod/moduzlib.c
@@ -31,6 +31,8 @@
#include "py/stream.h"
#include "py/mperrno.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_UZLIB
#include "../../lib/uzlib/src/tinf.h"
@@ -92,7 +94,7 @@ STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size
dict_opt = uzlib_zlib_parse_header(&o->decomp);
if (dict_opt < 0) {
header_error:
- mp_raise_ValueError("compression header");
+ mp_raise_ValueError(translate("compression header"));
}
dict_sz = 1 << dict_opt;
} else {
diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c
index cc6d97f41..781ec0d46 100644
--- a/extmod/uos_dupterm.c
+++ b/extmod/uos_dupterm.c
@@ -34,6 +34,8 @@
#include "py/stream.h"
#include "lib/utils/interrupt_char.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_OS_DUPTERM
void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) {
@@ -115,7 +117,7 @@ STATIC mp_obj_t mp_uos_dupterm(size_t n_args, const mp_obj_t *args) {
}
if (idx < 0 || idx >= MICROPY_PY_OS_DUPTERM) {
- mp_raise_ValueError("invalid dupterm index");
+ mp_raise_ValueError(translate("invalid dupterm index"));
}
mp_obj_t previous_obj = MP_STATE_VM(dupterm_objs[idx]);