Mercurial > cpython-lru_cache-weakref
diff Python/pystrtod.c @ 53489:de1d0f71e209
Issue #5835: Deprecate PyOS_ascii_formatd.
| author | Eric Smith <eric@trueblade.com> |
|---|---|
| date | Sun, 26 Apr 2009 21:35:14 +0000 |
| parents | 785ea299fe23 |
| children | 4b4b59f278bf |
line wrap: on
line diff
--- a/Python/pystrtod.c Sun Apr 26 21:26:45 2009 +0000 +++ b/Python/pystrtod.c Sun Apr 26 21:35:14 2009 +0000 @@ -433,7 +433,7 @@ * 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 @@ 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 @@ 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);
