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

@ -1466,14 +1466,14 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
CONVERT_TO_DOUBLE(v, self);
if (Py_IS_INFINITY(self)) {
PyErr_SetString(PyExc_OverflowError,
"Cannot pass infinity to float.as_integer_ratio.");
return NULL;
PyErr_SetString(PyExc_OverflowError,
"cannot convert Infinity to integer ratio");
return NULL;
}
if (Py_IS_NAN(self)) {
PyErr_SetString(PyExc_ValueError,
"Cannot pass NaN to float.as_integer_ratio.");
return NULL;
PyErr_SetString(PyExc_ValueError,
"cannot convert NaN to integer ratio");
return NULL;
}
PyFPE_START_PROTECT("as_integer_ratio", goto error);