Issue #7330: Implement width and precision (ex: "%5.3s") for the format string

of PyUnicode_FromFormat() function, original patch written by Ysj Ray.
This commit is contained in:
Victor Stinner 2013-05-06 23:11:54 +02:00
parent 9b5d4d8cef
commit 8cecc8c262
4 changed files with 294 additions and 96 deletions

View file

@ -526,12 +526,23 @@ APIs:
The `"%lld"` and `"%llu"` format specifiers are only available
when :const:`HAVE_LONG_LONG` is defined.
.. note::
The width formatter unit is number of characters rather than bytes.
The precision formatter unit is number of bytes for ``"%s"`` and
``"%V"`` (if the ``PyObject*`` argument is NULL), and a number of
characters for ``"%A"``, ``"%U"``, ``"%S"``, ``"%R"`` and ``"%V"``
(if the ``PyObject*`` argument is not NULL).
.. versionchanged:: 3.2
Support for ``"%lld"`` and ``"%llu"`` added.
.. versionchanged:: 3.3
Support for ``"%li"``, ``"%lli"`` and ``"%zi"`` added.
.. versionchanged:: 3.4
Support width and precision formatter for ``"%s"``, ``"%A"``, ``"%U"``,
``"%V"``, ``"%S"``, ``"%R"`` added.
.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)