py/obj: Add support for __int__ special method.
Based on the discussion, this special method is available unconditionally, as converting to int is a common operation.
This commit is contained in:
committed by
Damien George
parent
113f00a9ab
commit
b1d08726ee
@@ -62,8 +62,7 @@ STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args,
|
||||
return mp_obj_new_int_from_float(mp_obj_float_get(args[0]));
|
||||
#endif
|
||||
} else {
|
||||
// try to convert to small int (eg from bool)
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(args[0]));
|
||||
return mp_unary_op(MP_UNARY_OP_INT, args[0]);
|
||||
}
|
||||
|
||||
case 2:
|
||||
|
||||
Reference in New Issue
Block a user