summaryrefslogtreecommitdiff
path: root/py/objint.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2018-08-29 17:59:36 +0300
committerDamien George <damien.p.george@gmail.com>2018-12-07 17:28:04 +1100
commitb1d08726eeeadf0b91358cc8c46e156695b6a9c0 (patch)
treea8d8235ef2738961eab0ca0c2da74e85ecef861d /py/objint.c
parent113f00a9ab469a83d1004dac502077af0a8f4847 (diff)
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.
Diffstat (limited to 'py/objint.c')
-rw-r--r--py/objint.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/py/objint.c b/py/objint.c
index cd8f20c34..d5d74dd55 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -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: