summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2009-10-27 12:12:44 (GMT)
committerEric Smith <eric@trueblade.com>2009-10-27 12:12:44 (GMT)
commitb53e1a6ed36cfcd0e7452e3c41dc47e4224dfdd1 (patch)
treee6618b4749be8a1ac552e3200d554c711f061da1 /Modules
parent97be1ca1d9f385996e11cf157b3348392266e778 (diff)
downloadcpython-b53e1a6ed36cfcd0e7452e3c41dc47e4224dfdd1.zip
cpython-b53e1a6ed36cfcd0e7452e3c41dc47e4224dfdd1.tar.gz
cpython-b53e1a6ed36cfcd0e7452e3c41dc47e4224dfdd1.tar.bz2
Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/stropmodule.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 2d88474..7383194 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -879,10 +879,12 @@ strop_atof(PyObject *self, PyObject *args)
PyErr_SetString(PyExc_ValueError, "empty string for atof()");
return NULL;
}
- errno = 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)
+ if (x == -1 && PyErr_Occurred())
+ return NULL;
while (*end && isspace(Py_CHARMASK(*end)))
end++;
if (*end != '\0') {
@@ -891,12 +893,6 @@ strop_atof(PyObject *self, PyObject *args)
PyErr_SetString(PyExc_ValueError, buffer);
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);
}