Mercurial > cpython-lru_cache-weakref
diff Python/pystrtod.c @ 56999:bab3e3cd76f1 legacy-trunk
Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 31 Oct 2009 09:42:39 +0000 |
| parents | 74472da09f6c |
| children | 6b761817b717 |
line wrap: on
line diff
--- a/Python/pystrtod.c Sat Oct 31 09:28:12 2009 +0000 +++ b/Python/pystrtod.c Sat Oct 31 09:42:39 2009 +0000 @@ -270,6 +270,8 @@ #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 @@ 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 @@ 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 @@ 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) {
