diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-09-11 06:50:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-11 06:50:46 (GMT) |
commit | 2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59 (patch) | |
tree | b7f672d07435aff1060d27f20867365e637b8df9 /Objects | |
parent | 252033d50effa08046ac34fcc406bc99796ab88b (diff) | |
download | cpython-2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59.zip cpython-2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59.tar.gz cpython-2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59.tar.bz2 |
bpo-31373: remove overly strict float range checks (#3486)
This undoes a853a8ba7850381d49b284295dd6f0dc491dbe44 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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index fc1ddf4..8d7a55a 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -2233,13 +2233,13 @@ _PyFloat_Pack4(double x, unsigned char *p, int le) } else { + float y = (float)x; int i, incr = 1; - if (fabs(x) > FLT_MAX && !Py_IS_INFINITY(x)) + if (Py_IS_INFINITY(y) && !Py_IS_INFINITY(x)) goto Overflow; unsigned char s[sizeof(float)]; - float y = (float)x; memcpy(s, &y, sizeof(float)); if ((float_format == ieee_little_endian_format && !le) |