diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-09-07 11:35:03 -0700 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2017-09-07 11:35:03 -0700 |
commit | b03623227ed1264e3cac4e6bb4878d96b91aa484 (patch) | |
tree | 019511e476f77bf6ed4e2cbfd9c8280ff89d9e96 /Python/getargs.c | |
parent | b0d0217c0e4c1512a06ef306928b2fd8f82d046e (diff) | |
download | cpython-git-b03623227ed1264e3cac4e6bb4878d96b91aa484.tar.gz |
[3.6] fixes bpo-31373: fix undefined floating-point demotions (GH-3396) (#3424)
(cherry picked from commit a853a8ba7850381d49b284295dd6f0dc491dbe44)
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 616c6eb107..8fb19f34ec 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -4,6 +4,7 @@ #include "Python.h" #include <ctype.h> +#include <float.h> #ifdef __cplusplus @@ -810,6 +811,10 @@ 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; |