summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2022-07-04 17:35:46 +1000
committerDamien George <damien@micropython.org>2022-07-25 14:23:34 +1000
commit1e87b56219c69306d77a887cac3d29146180f113 (patch)
treec2e0dd58749e4ec4644407660a73d7db3201d940 /py/runtime.c
parentfa15aed0f718562871288aa174e91507a134db28 (diff)
py/obj: Add support for __float__ and __complex__ functions.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index e6d8c6807..2c3b3ddde 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -319,6 +319,15 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) {
// if arg==mp_const_none.
return mp_const_true;
}
+ #if MICROPY_PY_BUILTINS_FLOAT
+ if (op == MP_UNARY_OP_FLOAT_MAYBE
+ #if MICROPY_PY_BUILTINS_COMPLEX
+ || op == MP_UNARY_OP_COMPLEX_MAYBE
+ #endif
+ ) {
+ return MP_OBJ_NULL;
+ }
+ #endif
// With MP_UNARY_OP_INT, mp_unary_op() becomes a fallback for mp_obj_get_int().
// In this case provide a more focused error message to not confuse, e.g. chr(1.0)
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE