mirror of
https://github.com/python/cpython.git
synced 2025-10-04 22:20:46 +00:00
[3.6] fixes bpo-31373: fix undefined floating-point demotions (GH-3396) (#3424)
(cherry picked from commit a853a8ba78
)
This commit is contained in:
parent
b0d0217c0e
commit
b03623227e
5 changed files with 51 additions and 30 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue