summaryrefslogtreecommitdiff
path: root/py/objstrunicode.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-08-09 20:00:18 -0400
committerGitHub <noreply@github.com>2018-08-09 20:00:18 -0400
commitbbc034cd3dfc46ee7938faedc915fec91610c6a3 (patch)
tree4fe11d359088e41790030fce0763471b76ab3fb4 /py/objstrunicode.c
parentb735b9dbed2132f07793324a40770f4bd96d9ae8 (diff)
parent24e53ad5911f42efb6508b4a8dcf4a196a81494a (diff)
Merge pull request #1104 from tannewt/more_strings
Fixes and translate more strings.
Diffstat (limited to 'py/objstrunicode.c')
-rw-r--r--py/objstrunicode.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index ca41a7baa..03106f987 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -32,6 +32,8 @@
#include "py/objlist.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
#if MICROPY_PY_BUILTINS_STR_UNICODE
STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
@@ -129,7 +131,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (MP_OBJ_IS_SMALL_INT(index)) {
i = MP_OBJ_SMALL_INT_VALUE(index);
} else if (!mp_obj_get_int_maybe(index, &i)) {
- mp_raise_TypeError_varg("string indices must be integers, not %s", mp_obj_get_type_str(index));
+ mp_raise_TypeError_varg(translate("string indices must be integers, not %s"), mp_obj_get_type_str(index));
}
const byte *s, *top = self_data + self_len;
if (i < 0)
@@ -140,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;
}
- mp_raise_IndexError("string index out of range");
+ mp_raise_IndexError(translate("string index out of range"));
}
if (!UTF8_IS_CONT(*s)) {
++i;
@@ -159,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;
}
- mp_raise_IndexError("string index out of range");
+ mp_raise_IndexError(translate("string index out of range"));
}
// Then check completion
if (i-- == 0) {
@@ -186,7 +188,7 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
mp_obj_t ostart, ostop, ostep;
mp_obj_slice_get(index, &ostart, &ostop, &ostep);
if (ostep != mp_const_none && ostep != MP_OBJ_NEW_SMALL_INT(1)) {
- mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
+ mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported"));
}
const byte *pstart, *pstop;