mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
5aab44b301
commit
0d250bc119
5 changed files with 22 additions and 45 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue