summaryrefslogtreecommitdiffstats
path: root/Python/pystrtod.c
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2009-04-26 21:35:14 (GMT)
committerEric Smith <eric@trueblade.com>2009-04-26 21:35:14 (GMT)
commitcc32a11976364cccb91cd5554c299424d4d0f92f (patch)
tree46808592e1780353b7c1fa389a6ba3dbd285929b /Python/pystrtod.c
parent886b40aa8f9036d6b877f77f3c63abbc9653e50d (diff)
downloadcpython-cc32a11976364cccb91cd5554c299424d4d0f92f.zip
cpython-cc32a11976364cccb91cd5554c299424d4d0f92f.tar.gz
cpython-cc32a11976364cccb91cd5554c299424d4d0f92f.tar.bz2
Issue #5835: Deprecate PyOS_ascii_formatd.
Diffstat (limited to 'Python/pystrtod.c')
-rw-r--r--Python/pystrtod.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index b5dd93d..872cc37 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -433,7 +433,7 @@ ensure_decimal_point(char* buffer, size_t buf_size)
* Return value: The pointer to the buffer with the converted string.
**/
char *
-PyOS_ascii_formatd(char *buffer,
+_PyOS_ascii_formatd(char *buffer,
size_t buf_size,
const char *format,
double d)
@@ -508,6 +508,20 @@ PyOS_ascii_formatd(char *buffer,
return buffer;
}
+char *
+PyOS_ascii_formatd(char *buffer,
+ size_t buf_size,
+ const char *format,
+ double d)
+{
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "PyOS_ascii_formatd is deprecated, "
+ "use PyOS_double_to_string instead", 1) < 0)
+ return NULL;
+
+ return _PyOS_ascii_formatd(buffer, buf_size, format, d);
+}
+
#ifdef PY_NO_SHORT_FLOAT_REPR
/* The fallback code to use if _Py_dg_dtoa is not available. */
@@ -638,8 +652,10 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
if ((flags & Py_DTSF_ADD_DOT_0) && (format_code != 'e'))
format_code = 'Z';
- PyOS_snprintf(format, 32, "%%%s.%i%c", (flags & Py_DTSF_ALT ? "#" : ""), precision, format_code);
- PyOS_ascii_formatd(buf, sizeof(buf), format, val);
+ PyOS_snprintf(format, sizeof(format), "%%%s.%i%c",
+ (flags & Py_DTSF_ALT ? "#" : ""), precision,
+ format_code);
+ _PyOS_ascii_formatd(buf, sizeof(buf), format, val);
/* remove trailing zeros if necessary */
if (strip_trailing_zeros)
remove_trailing_zeros(buf);