mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Add _PyUnicodeWriter_WriteASCIIString() function
This commit is contained in:
parent
4d3f109ad3
commit
4a58707a34
4 changed files with 96 additions and 38 deletions
|
@ -1053,24 +1053,24 @@ format_float_internal(PyObject *value,
|
|||
n_digits += 1;
|
||||
}
|
||||
|
||||
/* Since there is no unicode version of PyOS_double_to_string,
|
||||
just use the 8 bit version and then convert to unicode. */
|
||||
unicode_tmp = _PyUnicode_FromASCII(buf, n_digits);
|
||||
PyMem_Free(buf);
|
||||
if (unicode_tmp == NULL)
|
||||
goto done;
|
||||
|
||||
if (format->sign != '+' && format->sign != ' '
|
||||
&& format->width == -1
|
||||
&& format->type != 'n'
|
||||
&& !format->thousands_separators)
|
||||
{
|
||||
/* Fast path */
|
||||
result = _PyUnicodeWriter_WriteStr(writer, unicode_tmp);
|
||||
Py_DECREF(unicode_tmp);
|
||||
result = _PyUnicodeWriter_WriteASCIIString(writer, buf, n_digits);
|
||||
PyMem_Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Since there is no unicode version of PyOS_double_to_string,
|
||||
just use the 8 bit version and then convert to unicode. */
|
||||
unicode_tmp = _PyUnicode_FromASCII(buf, n_digits);
|
||||
PyMem_Free(buf);
|
||||
if (unicode_tmp == NULL)
|
||||
goto done;
|
||||
|
||||
/* Is a sign character present in the output? If so, remember it
|
||||
and skip it */
|
||||
index = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue