[Python-checkins] r75745 - python/trunk/Modules/stropmodule.c

eric.smith python-checkins at python.org
Tue Oct 27 13:12:44 CET 2009


Author: eric.smith
Date: Tue Oct 27 13:12:44 2009
New Revision: 75745

Log:
Issue 7117: Replace PyOS_ascii_strtod with PyOS_string_to_double in stropmodule as part of short float repr.

Modified:
   python/trunk/Modules/stropmodule.c

Modified: python/trunk/Modules/stropmodule.c
==============================================================================
--- python/trunk/Modules/stropmodule.c	(original)
+++ python/trunk/Modules/stropmodule.c	Tue Oct 27 13:12:44 2009
@@ -879,10 +879,12 @@
 		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 @@
 		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);
 }
 


More information about the Python-checkins mailing list