diff options
author | Damien George <damien.p.george@gmail.com> | 2020-02-11 11:48:28 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-13 11:52:40 +1100 |
commit | ad7213d3c31bccb26a3f54f7492ccf4b0cc920f3 (patch) | |
tree | 2ab64a805c05d790579052f557a8168061afcebe /py/objstrunicode.c | |
parent | 97eca38c4f03e76bd464fb25974544a043af2a9e (diff) | |
download | micropython-ad7213d3c31bccb26a3f54f7492ccf4b0cc920f3.tar.gz micropython-ad7213d3c31bccb26a3f54f7492ccf4b0cc920f3.zip |
py: Add mp_raise_msg_varg helper and use it where appropriate.
This commit adds mp_raise_msg_varg(type, fmt, ...) as a helper for
nlr_raise(mp_obj_new_exception_msg_varg(type, fmt, ...)). It makes the
C-level API for raising exceptions more consistent, and reduces code size
on most ports:
bare-arm: +28 +0.042%
minimal x86: +100 +0.067%
unix x64: -56 -0.011%
unix nanbox: -300 -0.068%
stm32: -204 -0.054% PYBV10
cc3200: +0 +0.000%
esp8266: -64 -0.010% GENERIC
esp32: -104 -0.007% GENERIC
nrf: -136 -0.094% pca10040
samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
Diffstat (limited to 'py/objstrunicode.c')
-rw-r--r-- | py/objstrunicode.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c index e5a57ab942..c9bd6ee596 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -129,7 +129,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)) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "string indices must be integers, not %s", mp_obj_get_type_str(index))); + mp_raise_msg_varg(&mp_type_TypeError, "string indices must be integers, not %s", mp_obj_get_type_str(index)); } const byte *s, *top = self_data + self_len; if (i < 0) |