From ca6ea83ff5a25422028ebe11c2527af4b7f328d2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 23 Apr 2023 09:28:34 -0500 Subject: [PATCH] Fix `non_negative` validator to allow 0.0 --- py/argcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/argcheck.c b/py/argcheck.c index b530d44caa..265b303901 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -204,8 +204,8 @@ void mp_arg_validate_obj_float_range(mp_obj_t float_in, mp_int_t min, mp_int_t m mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t default_for_null, qstr arg_name) { const mp_float_t f = (float_in == MP_OBJ_NULL) ? default_for_null - : mp_obj_get_float(float_in); - if (f <= (mp_float_t)0.0) { + : mp_arg_validate_type_float(float_in, arg_name); + if (f < (mp_float_t)0.0) { mp_raise_ValueError_varg(translate("%q must be >= %d"), arg_name, 0); } return f;