From 0d250bc119489fa7d094d4a3fd2fd2fa0a508145 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 29 Dec 2015 22:34:23 +0200 Subject: 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. --- Lib/_pydecimal.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Lib/_pydecimal.py') diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index eb7bba8e93a..02365cad2c3 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -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 -- cgit v1.2.3