Issue #25971: Optimized creating Fractions from floats by 2 times and from

Decimals by 3 times.
Unified error messages in float.as_integer_ratio(), Decimal.as_integer_ratio(),
and Fraction constructors.
This commit is contained in:
Serhiy Storchaka 2015-12-29 22:34:23 +02:00
parent 5aab44b301
commit 0d250bc119
5 changed files with 22 additions and 45 deletions

View file

@ -1026,11 +1026,9 @@ class Decimal(object):
"""
if self._is_special:
if self.is_nan():
raise ValueError("Cannot pass NaN "
"to decimal.as_integer_ratio.")
raise ValueError("cannot convert NaN to integer ratio")
else:
raise OverflowError("Cannot pass infinity "
"to decimal.as_integer_ratio.")
raise OverflowError("cannot convert Infinity to integer ratio")
if not self:
return 0, 1