diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-05-03 20:33:40 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-05-03 20:33:40 (GMT) |
commit | 725bfd8489e444aedd8dfd686a27ffc308657155 (patch) | |
tree | 99d4e0cc2953794a67a5cff491e1897723a119ff /Python/ast.c | |
parent | 75930f85df76472686a8c4eb587a2a70562f61fe (diff) | |
download | cpython-725bfd8489e444aedd8dfd686a27ffc308657155.zip cpython-725bfd8489e444aedd8dfd686a27ffc308657155.tar.gz cpython-725bfd8489e444aedd8dfd686a27ffc308657155.tar.bz2 |
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.
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Python/ast.c b/Python/ast.c index b08cf9b..1c79359 100644 --- a/Python/ast.c +++ b/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); } } |