mirror of
https://github.com/python/cpython.git
synced 2025-10-25 10:44:55 +00:00
Issue #5914: Add new C-API function PyOS_string_to_double, to complement
PyOS_double_to_string, and deprecate PyOS_ascii_strtod and PyOS_ascii_atof.
This commit is contained in:
parent
75930f85df
commit
725bfd8489
10 changed files with 253 additions and 96 deletions
16
Python/ast.c
16
Python/ast.c
|
|
@ -3162,18 +3162,18 @@ parsenumber(struct compiling *c, const char *s)
|
|||
#ifndef WITHOUT_COMPLEX
|
||||
if (imflag) {
|
||||
compl.real = 0.;
|
||||
PyFPE_START_PROTECT("atof", return 0)
|
||||
compl.imag = PyOS_ascii_atof(s);
|
||||
PyFPE_END_PROTECT(c)
|
||||
return PyComplex_FromCComplex(compl);
|
||||
compl.imag = PyOS_string_to_double(s, (char **)&end, NULL);
|
||||
if (compl.imag == -1.0 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return PyComplex_FromCComplex(compl);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PyFPE_START_PROTECT("atof", return 0)
|
||||
dx = PyOS_ascii_atof(s);
|
||||
PyFPE_END_PROTECT(dx)
|
||||
return PyFloat_FromDouble(dx);
|
||||
dx = PyOS_string_to_double(s, NULL, NULL);
|
||||
if (dx == -1.0 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(dx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue