Add support for int(r) just like the other numeric classes.
diff --git a/Lib/rational.py b/Lib/rational.py
index 60cd129..6824f4a 100755
--- a/Lib/rational.py
+++ b/Lib/rational.py
@@ -376,6 +376,8 @@
else:
return a.numerator // a.denominator
+ __int__ = __trunc__
+
def __floor__(a):
"""Will be math.floor(a) in 3.0."""
return a.numerator // a.denominator
diff --git a/Lib/test/test_rational.py b/Lib/test/test_rational.py
index 0f0a48d..3242e43 100644
--- a/Lib/test/test_rational.py
+++ b/Lib/test/test_rational.py
@@ -160,6 +160,7 @@
def testConversions(self):
self.assertTypedEquals(-1, trunc(R(-11, 10)))
+ self.assertTypedEquals(-1, int(R(-11, 10)))
self.assertTypedEquals(-2, R(-11, 10).__floor__())
self.assertTypedEquals(-1, R(-11, 10).__ceil__())
self.assertTypedEquals(-1, R(-10, 10).__ceil__())