From b03623227ed1264e3cac4e6bb4878d96b91aa484 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 7 Sep 2017 11:35:03 -0700 Subject: [3.6] fixes bpo-31373: fix undefined floating-point demotions (GH-3396) (#3424) (cherry picked from commit a853a8ba7850381d49b284295dd6f0dc491dbe44) --- Python/getargs.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Python/getargs.c') 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 +#include #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; -- cgit v1.2.1