From 416eadf9627398467cd1aea4eecf17ddedb8dbe3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 8 Apr 2026 11:43:41 +1000 Subject: [PATCH] ports: Use mp_obj_is_float instead of mp_obj_is_type. `mp_obj_is_float` must be used in case the object representation is C or D. Signed-off-by: Damien George --- ports/renesas-ra/timer.c | 2 +- ports/stm32/timer.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/renesas-ra/timer.c b/ports/renesas-ra/timer.c index 286bc4d0fb..5038936a83 100644 --- a/ports/renesas-ra/timer.c +++ b/ports/renesas-ra/timer.c @@ -339,7 +339,7 @@ static mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args) { uint32_t freq; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_type(args[1], &mp_type_float)) { + } else if (mp_obj_is_float(args[1])) { freq = (int)mp_obj_get_float(args[1]); #endif } else { diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index a2f48139ee..d70878267e 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -450,7 +450,7 @@ static uint32_t compute_prescaler_period_from_freq(pyb_timer_obj_t *self, mp_obj uint32_t period; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_type(freq_in, &mp_type_float)) { + } else if (mp_obj_is_float(freq_in)) { float freq = mp_obj_get_float_to_f(freq_in); if (freq <= 0) { goto bad_freq; @@ -545,7 +545,7 @@ static uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent uint32_t cmp; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (mp_obj_is_type(percent_in, &mp_type_float)) { + } else if (mp_obj_is_float(percent_in)) { mp_float_t percent = mp_obj_get_float(percent_in); if (percent <= 0.0) { cmp = 0;