mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31373: fix undefined floating-point demotions (#3396)
This commit is contained in:
parent
c988ae01fe
commit
a853a8ba78
5 changed files with 51 additions and 30 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue