diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-09-07 18:13:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-07 18:13:59 (GMT) |
commit | a853a8ba7850381d49b284295dd6f0dc491dbe44 (patch) | |
tree | db901475288d8942c221c336fc4ad61f596761c3 /Python/getargs.c | |
parent | c988ae01fec2e0510d53728e01a5e4bb06761bda (diff) | |
download | cpython-a853a8ba7850381d49b284295dd6f0dc491dbe44.zip cpython-a853a8ba7850381d49b284295dd6f0dc491dbe44.tar.gz cpython-a853a8ba7850381d49b284295dd6f0dc491dbe44.tar.bz2 |
bpo-31373: fix undefined floating-point demotions (#3396)
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 4b969d9..0b155a1 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -4,6 +4,7 @@ #include "Python.h" #include <ctype.h> +#include <float.h> #ifdef __cplusplus @@ -858,6 +859,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; |