diff options
| author | Damien George | 2020-02-11 11:48:28 +1100 |
|---|---|---|
| committer | Damien George | 2020-02-13 11:52:40 +1100 |
| commit | ad7213d3c31bccb26a3f54f7492ccf4b0cc920f3 (patch) | |
| tree | 2ab64a805c05d790579052f557a8168061afcebe /ports/pic16bit | |
| parent | 97eca38c4f03e76bd464fb25974544a043af2a9e (diff) | |
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 'ports/pic16bit')
| -rw-r--r-- | ports/pic16bit/modpybled.c | 2 | ||||
| -rw-r--r-- | ports/pic16bit/modpybswitch.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/ports/pic16bit/modpybled.c b/ports/pic16bit/modpybled.c index 0d200c603..eb34865f2 100644 --- a/ports/pic16bit/modpybled.c +++ b/ports/pic16bit/modpybled.c @@ -50,7 +50,7 @@ STATIC mp_obj_t pyb_led_make_new(const mp_obj_type_t *type, size_t n_args, size_ mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_int_t led_id = mp_obj_get_int(args[0]); if (!(1 <= led_id && led_id <= NUM_LED)) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LED %d does not exist", led_id)); + mp_raise_msg_varg(&mp_type_ValueError, "LED %d does not exist", led_id); } return (mp_obj_t)&pyb_led_obj[led_id - 1]; } diff --git a/ports/pic16bit/modpybswitch.c b/ports/pic16bit/modpybswitch.c index 0799ad9e8..924cce6ef 100644 --- a/ports/pic16bit/modpybswitch.c +++ b/ports/pic16bit/modpybswitch.c @@ -49,7 +49,7 @@ STATIC mp_obj_t pyb_switch_make_new(const mp_obj_type_t *type, size_t n_args, si mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_int_t sw_id = mp_obj_get_int(args[0]); if (!(1 <= sw_id && sw_id <= NUM_SWITCH)) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Switch %d does not exist", sw_id)); + mp_raise_msg_varg(&mp_type_ValueError, "Switch %d does not exist", sw_id); } return (mp_obj_t)&pyb_switch_obj[sw_id - 1]; } |
