From 4468731e3d039a3f72ac25aa43e936cf5ebb3f78 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Tue, 15 Aug 2017 23:37:14 +0200 Subject: [PATCH] nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...) --- nrf/modules/machine/pin.c | 2 +- nrf/modules/music/modmusic.c | 8 ++++---- nrf/modules/uos/moduos.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nrf/modules/machine/pin.c b/nrf/modules/machine/pin.c index 126ec02d3f..62160d785f 100644 --- a/nrf/modules/machine/pin.c +++ b/nrf/modules/machine/pin.c @@ -125,7 +125,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) { pin_obj = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj); if (pin_obj != mp_const_none) { if (!MP_OBJ_IS_TYPE(pin_obj, &pin_type)) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Pin.mapper didn't return a Pin object")); + mp_raise_ValueError("Pin.mapper didn't return a Pin object"); } if (pin_class_debug) { printf("Pin.mapper maps "); diff --git a/nrf/modules/music/modmusic.c b/nrf/modules/music/modmusic.c index 13efc18bf8..c2afc341cb 100644 --- a/nrf/modules/music/modmusic.c +++ b/nrf/modules/music/modmusic.c @@ -287,7 +287,7 @@ STATIC mp_obj_t microbit_music_stop(mp_uint_t n_args, const mp_obj_t *args) { #ifdef MICROPY_HW_MUSIC_PIN pin = &MICROPY_HW_MUSIC_PIN; #else - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given")); + mp_raise_ValueError("pin parameter not given"); #endif } else { pin = (pin_obj_t *)args[0]; @@ -340,7 +340,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args, #ifdef MICROPY_HW_MUSIC_PIN pin = &MICROPY_HW_MUSIC_PIN; #else - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given")); + mp_raise_ValueError("pin parameter not given"); #endif } else { pin = (pin_obj_t *)args[1].u_obj; @@ -395,7 +395,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args, #ifdef MICROPY_HW_MUSIC_PIN pin = &MICROPY_HW_MUSIC_PIN; #else - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given")); + mp_raise_ValueError("pin parameter not given"); #endif } else { pin = (pin_obj_t *)args[2].u_obj; @@ -411,7 +411,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args, //TODO: pwm_release(pin->name); } else if (pwm_set_period_us(1000000/frequency)) { pwm_release(pin->pin); // TODO: remove pin setting. - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid pitch")); + mp_raise_ValueError("invalid pitch"); } if (duration >= 0) { // use async machinery to stop the pitch after the duration diff --git a/nrf/modules/uos/moduos.c b/nrf/modules/uos/moduos.c index 50ca9a90ef..84671bc59d 100644 --- a/nrf/modules/uos/moduos.c +++ b/nrf/modules/uos/moduos.c @@ -121,7 +121,7 @@ STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) { } else if (mp_obj_get_type(args[0]) == &machine_hard_uart_type) { MP_STATE_PORT(pyb_stdio_uart) = args[0]; } else { - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "need a UART object")); + mp_raise_ValueError("need a UART object"); } return mp_const_none; }