summaryrefslogtreecommitdiffstats
path: root/Python/formatter_unicode.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-19 11:54:53 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-19 11:54:53 (GMT)
commit4a58707a340cacea6f8e6a82adfcc10a230e1185 (patch)
tree93f42c1524db7e6ba8a60f9a1f2c656c6e0931d9 /Python/formatter_unicode.c
parent4d3f109ad3d1870130816b94a1f5d6f6c1a07586 (diff)
downloadcpython-4a58707a340cacea6f8e6a82adfcc10a230e1185.zip
cpython-4a58707a340cacea6f8e6a82adfcc10a230e1185.tar.gz
cpython-4a58707a340cacea6f8e6a82adfcc10a230e1185.tar.bz2
Add _PyUnicodeWriter_WriteASCIIString() function
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index e68087f..0a3cc59 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -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;