diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-09-12 06:08:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 06:08:49 (GMT) |
commit | cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a (patch) | |
tree | ae90d2a83114d93250692df87b5c811488e8e1a7 /Objects | |
parent | 99b941b420d63027654dc6722f1648a8f36d2925 (diff) | |
download | cpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.zip cpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.tar.gz cpython-cb356c2ecc0528d47fee2b9f4b32da4fcfb48b3a.tar.bz2 |
[3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)
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.
(cherry picked from commit 2bb69a5b4e7f96cb35d1b28aa7b7b3974b351f59)
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 1803a68..1f134aa 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -2182,13 +2182,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) |