diff options
author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2022-07-04 17:35:46 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-07-25 14:23:34 +1000 |
commit | 1e87b56219c69306d77a887cac3d29146180f113 (patch) | |
tree | c2e0dd58749e4ec4644407660a73d7db3201d940 /py/runtime.c | |
parent | fa15aed0f718562871288aa174e91507a134db28 (diff) |
py/obj: Add support for __float__ and __complex__ functions.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 9 |
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 |