mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr.
This commit is contained in:
parent
97be1ca1d9
commit
b53e1a6ed3
1 changed files with 4 additions and 8 deletions
|
|
@ -879,10 +879,12 @@ strop_atof(PyObject *self, PyObject *args)
|
||||||
PyErr_SetString(PyExc_ValueError, "empty string for atof()");
|
PyErr_SetString(PyExc_ValueError, "empty string for atof()");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
errno = 0;
|
|
||||||
PyFPE_START_PROTECT("strop_atof", return 0)
|
PyFPE_START_PROTECT("strop_atof", return 0)
|
||||||
x = PyOS_ascii_strtod(s, &end);
|
x = PyOS_string_to_double(s, &end, PyExc_OverflowError);
|
||||||
PyFPE_END_PROTECT(x)
|
PyFPE_END_PROTECT(x)
|
||||||
|
if (x == -1 && PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
while (*end && isspace(Py_CHARMASK(*end)))
|
while (*end && isspace(Py_CHARMASK(*end)))
|
||||||
end++;
|
end++;
|
||||||
if (*end != '\0') {
|
if (*end != '\0') {
|
||||||
|
|
@ -891,12 +893,6 @@ strop_atof(PyObject *self, PyObject *args)
|
||||||
PyErr_SetString(PyExc_ValueError, buffer);
|
PyErr_SetString(PyExc_ValueError, buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (errno != 0) {
|
|
||||||
PyOS_snprintf(buffer, sizeof(buffer),
|
|
||||||
"atof() literal too large: %.200s", s);
|
|
||||||
PyErr_SetString(PyExc_ValueError, buffer);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return PyFloat_FromDouble(x);
|
return PyFloat_FromDouble(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue