diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-08-08 18:24:49 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-09 13:29:30 -0700 |
| commit | 96ebf5bc3fb455162286b9bc31e763f3c4f1c457 (patch) | |
| tree | 3d06bc866bcf943a0e0ea881a1fcab9826291a1c /py/objgenerator.c | |
| parent | 9da79c880e387ab05a683b67feb8f3da600d937d (diff) | |
Two fixes and translate more strings.
* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
Diffstat (limited to 'py/objgenerator.c')
| -rw-r--r-- | py/objgenerator.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/py/objgenerator.c b/py/objgenerator.c index 5664052f5..01d42ba94 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -34,6 +34,8 @@ #include "py/objfun.h" #include "py/stackctrl.h" +#include "supervisor/shared/translate.h" + /******************************************************************************/ /* generator wrapper */ @@ -103,7 +105,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ } if (self->code_state.sp == self->code_state.state - 1) { if (send_value != mp_const_none) { - mp_raise_TypeError("can't send non-None value to a just-started generator"); + mp_raise_TypeError(translate("can't send non-None value to a just-started generator")); } } else { #if MICROPY_PY_GENERATOR_PEND_THROW @@ -121,7 +123,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ // We set self->globals=NULL while executing, for a sentinel to ensure the generator // cannot be reentered during execution if (self->globals == NULL) { - mp_raise_ValueError("generator already executing"); + mp_raise_ValueError(translate("generator already executing")); } // Set up the correct globals context for the generator and execute it @@ -224,7 +226,7 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) { mp_obj_t ret; switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) { case MP_VM_RETURN_YIELD: - mp_raise_RuntimeError("generator ignored GeneratorExit"); + mp_raise_RuntimeError(translate("generator ignored GeneratorExit")); // Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other case MP_VM_RETURN_EXCEPTION: @@ -246,7 +248,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close); STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) { mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); if (self->code_state.sp == self->code_state.state - 1) { - mp_raise_TypeError("can't pend throw to just-started generator"); + mp_raise_TypeError(translate("can't pend throw to just-started generator")); } mp_obj_t prev = *self->code_state.sp; *self->code_state.sp = exc_in; |
