bpo-37942: Improve argument clinic float converter (GH-15470)

This commit is contained in:
Raymond Hettinger 2019-08-24 19:10:39 -07:00 committed by GitHub
parent 805f8f9afe
commit aef9ad82f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 317 additions and 112 deletions

View file

@ -887,7 +887,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'f': {/* float */
float *p = va_arg(*p_va, float *);
double dval = PyFloat_AsDouble(arg);
if (PyErr_Occurred())
if (dval == -1.0 && PyErr_Occurred())
RETURN_ERR_OCCURRED;
else
*p = (float) dval;
@ -897,7 +897,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'd': {/* double */
double *p = va_arg(*p_va, double *);
double dval = PyFloat_AsDouble(arg);
if (PyErr_Occurred())
if (dval == -1.0 && PyErr_Occurred())
RETURN_ERR_OCCURRED;
else
*p = dval;