mirror of
https://github.com/python/cpython.git
synced 2025-10-08 16:11:51 +00:00
[3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)
This undoesa853a8ba78
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 commit2bb69a5b4e
)
This commit is contained in:
parent
99b941b420
commit
cb356c2ecc
4 changed files with 14 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue