summaryrefslogtreecommitdiffstats
path: root/Lib/fractions.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-07-10 10:28:41 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-07-10 10:28:41 (GMT)
commit548db58e0264385026c892c524522e82f8468fa5 (patch)
tree760550eb406059bc00f3752cf253cbb652db31d4 /Lib/fractions.py
parent655d583a493e6ea03758011857945f290528658a (diff)
downloadcpython-548db58e0264385026c892c524522e82f8468fa5.zip
cpython-548db58e0264385026c892c524522e82f8468fa5.tar.gz
cpython-548db58e0264385026c892c524522e82f8468fa5.tar.bz2
Use operator.index() instead of n.__index__().
Diffstat (limited to 'Lib/fractions.py')
-rwxr-xr-xLib/fractions.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/fractions.py b/Lib/fractions.py
index 944e1fc..6bde774 100755
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -96,11 +96,8 @@ class Fraction(Rational):
if denominator == 0:
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
- try:
- numerator = numerator.__index__()
- denominator = denominator.__index__()
- except AttributeError:
- raise TypeError('Numerator and denominator must support __index__.')
+ numerator = operator.index(numerator)
+ denominator = operator.index(denominator)
g = gcd(numerator, denominator)
self._numerator = numerator // g
self._denominator = denominator // g