Kaydet (Commit) 88c38b32 authored tarafından Louie Lu's avatar Louie Lu Kaydeden (comit) Xiang Zhang

bpo-28415: Note 0 conversion different between Python and C (#885)

üst a90b9904
...@@ -72,29 +72,29 @@ called with a non-bytes parameter. ...@@ -72,29 +72,29 @@ called with a non-bytes parameter.
| :attr:`%c` | int | A single byte, | | :attr:`%c` | int | A single byte, |
| | | represented as a C int. | | | | represented as a C int. |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%d` | int | Exactly equivalent to | | :attr:`%d` | int | Equivalent to |
| | | ``printf("%d")``. | | | | ``printf("%d")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%u` | unsigned int | Exactly equivalent to | | :attr:`%u` | unsigned int | Equivalent to |
| | | ``printf("%u")``. | | | | ``printf("%u")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%ld` | long | Exactly equivalent to | | :attr:`%ld` | long | Equivalent to |
| | | ``printf("%ld")``. | | | | ``printf("%ld")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%lu` | unsigned long | Exactly equivalent to | | :attr:`%lu` | unsigned long | Equivalent to |
| | | ``printf("%lu")``. | | | | ``printf("%lu")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%zd` | Py_ssize_t | Exactly equivalent to | | :attr:`%zd` | Py_ssize_t | Equivalent to |
| | | ``printf("%zd")``. | | | | ``printf("%zd")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%zu` | size_t | Exactly equivalent to | | :attr:`%zu` | size_t | Equivalent to |
| | | ``printf("%zu")``. | | | | ``printf("%zu")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%i` | int | Exactly equivalent to | | :attr:`%i` | int | Equivalent to |
| | | ``printf("%i")``. | | | | ``printf("%i")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%x` | int | Exactly equivalent to | | :attr:`%x` | int | Equivalent to |
| | | ``printf("%x")``. | | | | ``printf("%x")``. [1]_ |
+-------------------+---------------+--------------------------------+ +-------------------+---------------+--------------------------------+
| :attr:`%s` | const char\* | A null-terminated C character | | :attr:`%s` | const char\* | A null-terminated C character |
| | | array. | | | | array. |
...@@ -111,6 +111,9 @@ called with a non-bytes parameter. ...@@ -111,6 +111,9 @@ called with a non-bytes parameter.
An unrecognized format character causes all the rest of the format string to be An unrecognized format character causes all the rest of the format string to be
copied as-is to the result object, and any extra arguments discarded. copied as-is to the result object, and any extra arguments discarded.
.. [1] For integer specifiers (d, u, ld, lu, zd, zu, i, x): the 0-conversion
flag has effect even when a precision is given.
.. c:function:: PyObject* PyBytes_FromFormatV(const char *format, va_list vargs) .. c:function:: PyObject* PyBytes_FromFormatV(const char *format, va_list vargs)
......
...@@ -451,44 +451,44 @@ APIs: ...@@ -451,44 +451,44 @@ APIs:
| :attr:`%c` | int | A single character, | | :attr:`%c` | int | A single character, |
| | | represented as a C int. | | | | represented as a C int. |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%d` | int | Exactly equivalent to | | :attr:`%d` | int | Equivalent to |
| | | ``printf("%d")``. | | | | ``printf("%d")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%u` | unsigned int | Exactly equivalent to | | :attr:`%u` | unsigned int | Equivalent to |
| | | ``printf("%u")``. | | | | ``printf("%u")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%ld` | long | Exactly equivalent to | | :attr:`%ld` | long | Equivalent to |
| | | ``printf("%ld")``. | | | | ``printf("%ld")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%li` | long | Exactly equivalent to | | :attr:`%li` | long | Equivalent to |
| | | ``printf("%li")``. | | | | ``printf("%li")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%lu` | unsigned long | Exactly equivalent to | | :attr:`%lu` | unsigned long | Equivalent to |
| | | ``printf("%lu")``. | | | | ``printf("%lu")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%lld` | long long | Exactly equivalent to | | :attr:`%lld` | long long | Equivalent to |
| | | ``printf("%lld")``. | | | | ``printf("%lld")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%lli` | long long | Exactly equivalent to | | :attr:`%lli` | long long | Equivalent to |
| | | ``printf("%lli")``. | | | | ``printf("%lli")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%llu` | unsigned long long | Exactly equivalent to | | :attr:`%llu` | unsigned long long | Equivalent to |
| | | ``printf("%llu")``. | | | | ``printf("%llu")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%zd` | Py_ssize_t | Exactly equivalent to | | :attr:`%zd` | Py_ssize_t | Equivalent to |
| | | ``printf("%zd")``. | | | | ``printf("%zd")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%zi` | Py_ssize_t | Exactly equivalent to | | :attr:`%zi` | Py_ssize_t | Equivalent to |
| | | ``printf("%zi")``. | | | | ``printf("%zi")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%zu` | size_t | Exactly equivalent to | | :attr:`%zu` | size_t | Equivalent to |
| | | ``printf("%zu")``. | | | | ``printf("%zu")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%i` | int | Exactly equivalent to | | :attr:`%i` | int | Equivalent to |
| | | ``printf("%i")``. | | | | ``printf("%i")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%x` | int | Exactly equivalent to | | :attr:`%x` | int | Equivalent to |
| | | ``printf("%x")``. | | | | ``printf("%x")``. [1]_ |
+-------------------+---------------------+--------------------------------+ +-------------------+---------------------+--------------------------------+
| :attr:`%s` | const char\* | A null-terminated C character | | :attr:`%s` | const char\* | A null-terminated C character |
| | | array. | | | | array. |
...@@ -530,6 +530,9 @@ APIs: ...@@ -530,6 +530,9 @@ APIs:
characters for ``"%A"``, ``"%U"``, ``"%S"``, ``"%R"`` and ``"%V"`` characters for ``"%A"``, ``"%U"``, ``"%S"``, ``"%R"`` and ``"%V"``
(if the ``PyObject*`` argument is not NULL). (if the ``PyObject*`` argument is not NULL).
.. [1] For integer specifiers (d, u, ld, li, lu, lld, lli, llu, zd, zi,
zu, i, x): the 0-conversion flag has effect even when a precision is given.
.. versionchanged:: 3.2 .. versionchanged:: 3.2
Support for ``"%lld"`` and ``"%llu"`` added. Support for ``"%lld"`` and ``"%llu"`` added.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment