mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
py/obj: Accept user types in mp_obj_get_int_maybe.
This is possible now that MP_UNARY_OP_INT_MAYBE exists. As a consequence mp_obj_get_int now also supports user types, which was previously possible with MP_UNARY_OP_INT but no tests existed for it. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -13,6 +13,12 @@ print("=%s=" % [1, 2])
|
||||
print("=%s=" % "str")
|
||||
print("=%r=" % "str")
|
||||
|
||||
# test calling __int__
|
||||
class A:
|
||||
def __int__(self):
|
||||
return 123
|
||||
print("%d" % A())
|
||||
|
||||
try:
|
||||
print("=%s=%s=" % 1)
|
||||
except TypeError:
|
||||
|
||||
Reference in New Issue
Block a user