]> granicus.if.org Git - python/commitdiff
Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as...
authorEric Smith <eric@trueblade.com>
Tue, 27 Oct 2009 12:12:44 +0000 (12:12 +0000)
committerEric Smith <eric@trueblade.com>
Tue, 27 Oct 2009 12:12:44 +0000 (12:12 +0000)
Modules/stropmodule.c

index 2d884744aa7fe78e472a964c935c0dcbd6d64ef9..7383194a7e2f937f3d2dea0885bce136389b516b 100644 (file)
@@ -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);
 }