Issue #5835: Deprecate PyOS_ascii_formatd.

This commit is contained in:
Eric Smith 2009-04-26 21:35:14 +00:00
parent 886b40aa8f
commit cc32a11976
3 changed files with 58 additions and 3 deletions

View file

@ -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);