summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-10-31 09:42:39 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-10-31 09:42:39 (GMT)
commit09823a2e215bea1bde9941766f8d11c0aee26b76 (patch)
tree7a7a59a08e560f7c33442ddda1205c9318b2bd12 /Python
parentba26b39115bfaba16855ca30cd6ca0e3515fe0b6 (diff)
downloadcpython-09823a2e215bea1bde9941766f8d11c0aee26b76.zip
cpython-09823a2e215bea1bde9941766f8d11c0aee26b76.tar.gz
cpython-09823a2e215bea1bde9941766f8d11c0aee26b76.tar.bz2
Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double.
Diffstat (limited to 'Python')
-rw-r--r--Python/pystrtod.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 64bf73d..27ddc94 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -270,6 +270,8 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
#endif
+/* PyOS_ascii_strtod is DEPRECATED in Python 2.7 and 3.1 */
+
double
PyOS_ascii_strtod(const char *nptr, char **endptr)
{
@@ -277,6 +279,12 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
const char *p;
double x;
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "PyOS_ascii_strtod and PyOS_ascii_atof are "
+ "deprecated. Use PyOS_string_to_double "
+ "instead.", 1) < 0)
+ return -1.0;
+
/* _PyOS_ascii_strtod already does everything that we want,
except that it doesn't parse leading whitespace */
p = nptr;
@@ -290,13 +298,15 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
return x;
}
+/* PyOS_ascii_strtod is DEPRECATED in Python 2.7 and 3.1 */
+
double
PyOS_ascii_atof(const char *nptr)
{
return PyOS_ascii_strtod(nptr, NULL);
}
-/* PyOS_string_to_double is the recommended replacement for the
+/* PyOS_string_to_double is the recommended replacement for the deprecated
PyOS_ascii_strtod and PyOS_ascii_atof functions. It converts a
null-terminated byte string s (interpreted as a string of ASCII characters)
to a float. The string should not have leading or trailing whitespace (in
@@ -332,7 +342,7 @@ PyOS_string_to_double(const char *s,
errno = 0;
PyFPE_START_PROTECT("PyOS_string_to_double", return -1.0)
- x = PyOS_ascii_strtod(s, &fail_pos);
+ x = _PyOS_ascii_strtod(s, &fail_pos);
PyFPE_END_PROTECT(x)
if (errno == ENOMEM) {