Issue 3188: accept float('infinity') as well as float('inf'). This

makes the float constructor behave in the same way as specified
by various other language standards, including C99, IEEE 754r,
and the IBM Decimal standard.
This commit is contained in:
Mark Dickinson 2008-07-05 11:33:52 +00:00
parent e78fbcce3e
commit bf9f4d8015
2 changed files with 20 additions and 1 deletions

View file

@ -246,6 +246,9 @@ PyFloat_FromString(PyObject *v, char **pend)
if (PyOS_strnicmp(p, "inf", 4) == 0) {
Py_RETURN_INF(sign);
}
if (PyOS_strnicmp(p, "infinity", 9) == 0) {
Py_RETURN_INF(sign);
}
#ifdef Py_NAN
if(PyOS_strnicmp(p, "nan", 4) == 0) {
Py_RETURN_NAN;