[3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)

This undoes a853a8ba78 except for the pytime.c
parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be
rounded into finite floats. Tests were added to very this behavior.
(cherry picked from commit 2bb69a5b4e)
This commit is contained in:
Benjamin Peterson 2017-09-11 23:08:49 -07:00 committed by GitHub
parent 99b941b420
commit cb356c2ecc
4 changed files with 14 additions and 6 deletions

View file

@ -811,10 +811,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
double dval = PyFloat_AsDouble(arg);
if (PyErr_Occurred())
RETURN_ERR_OCCURRED;
else if (dval > FLT_MAX)
*p = (float)INFINITY;
else if (dval < -FLT_MAX)
*p = (float)-INFINITY;
else
*p = (float) dval;
break;