summaryrefslogtreecommitdiff
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2017-09-07 11:13:59 -0700
committerGitHub <noreply@github.com>2017-09-07 11:13:59 -0700
commita853a8ba7850381d49b284295dd6f0dc491dbe44 (patch)
treedb901475288d8942c221c336fc4ad61f596761c3 /Python/getargs.c
parentc988ae01fec2e0510d53728e01a5e4bb06761bda (diff)
downloadcpython-git-a853a8ba7850381d49b284295dd6f0dc491dbe44.tar.gz
bpo-31373: fix undefined floating-point demotions (#3396)
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 4b969d924a..0b155a170f 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;