mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
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:
parent
e78fbcce3e
commit
bf9f4d8015
2 changed files with 20 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue