mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
py/obj: Add support for __float__ and __complex__ functions.
This commit is contained in:
committed by
Damien George
parent
fa15aed0f7
commit
1e87b56219
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user