@@ -47,15 +47,15 @@ Unless otherwise stated, buffers are not NUL-terminated.
4747
4848There are three ways strings and buffers can be converted to C:
4949
50- *  Formats such as ``y* `` and ``s* `` fill a :c:type: `Py_buffer ` structure.
50+ *  Formats such as ``"y*" `` and ``"s*" `` fill a :c:type: `Py_buffer ` structure.
5151   This locks the underlying buffer so that the caller can subsequently use
5252   the buffer even inside a :c:type: `Py_BEGIN_ALLOW_THREADS `
5353   block without the risk of mutable data being resized or destroyed.
5454   As a result, **you have to call ** :c:func: `PyBuffer_Release ` after you have
5555   finished processing the data (or in any early abort case).
5656
57- *  The ``es ``, ``es# ``, ``et `` and ``et# `` formats allocate the result buffer. 
58-    **You have to call ** :c:func: `PyMem_Free ` after you have finished
57+ *  The ``"es" ``, ``" es#"  ``, ``"et" `` and ``" et#"  `` formats allocate the result
58+    buffer.  **You have to call ** :c:func: `PyMem_Free ` after you have finished
5959   processing the data (or in any early abort case).
6060
6161*  .. _c-arg-borrowed-buffer:
@@ -77,7 +77,7 @@ There are three ways strings and buffers can be converted to C:
7777   whether the input object is immutable (e.g. whether it would honor a request
7878   for a writable buffer, or whether another thread can mutate the data).
7979
80- ``s `` (:class:  ` str `) [const char  \* ]
80+ ``"s" `` (:ctype:  ` PyUnicodeObject \*  `) [:ctype: ` const char\*  ` ]
8181   Convert a Unicode object to a C pointer to a character string.
8282   A pointer to an existing string is stored in the character pointer
8383   variable whose address you pass.  The C string is NUL-terminated.
@@ -90,43 +90,51 @@ There are three ways strings and buffers can be converted to C:
9090      This format does not accept :term: `bytes-like objects 
9191      <bytes-like object> `.  If you want to accept
9292      filesystem paths and convert them to C character strings, it is
93-       preferable to use the ``O& `` format with :c:func: `PyUnicode_FSConverter `
93+       preferable to use the ``"O&" `` format with :c:func: `PyUnicode_FSConverter `
9494      as *converter *.
9595
9696   .. versionchanged :: 3.5 
9797      Previously, :exc: `TypeError ` was raised when embedded null code points
9898      were encountered in the Python string.
9999
100- ``s* `` (:class: `str ` or :term: `bytes-like object `) [Py_buffer]
100+ ``"s*" `` (:ctype: `PyUnicodeObject\*  `, :ctype: `PyBytesObject\*  `,
101+           :ctype: `PyByteArrayObject\*  ` or :term: `bytes-like object `) [:ctype: `Py_buffer `]
101102   This format accepts Unicode objects as well as bytes-like objects.
102103   It fills a :c:type: `Py_buffer ` structure provided by the caller.
103104   In this case the resulting C string may contain embedded NUL bytes.
104105   Unicode objects are converted to C strings using ``'utf-8' `` encoding.
105106
106- ``s# `` (:class: `str `, read-only :term: `bytes-like object `) [const char \* , :c:type: `Py_ssize_t `]
107-    Like ``s* ``, except that it provides a :ref: `borrowed buffer  <c-arg-borrowed-buffer >`.
107+ ``"s#" `` (:ctype: `PyUnicodeObject\*  `, :ctype: `PyBytesObject\*  ` or read-only
108+           :term: `bytes-like object `) [:ctype: `const char\*  `, :ctype: `int ` or
109+           :ctype: `Py_ssize_t `]
110+    Like ``"s*" ``, except that it provides a :ref: `borrowed buffer  <c-arg-borrowed-buffer >`.
108111   The result is stored into two C variables,
109112   the first one a pointer to a C string, the second one its length.
110113   The string may contain embedded null bytes. Unicode objects are converted
111114   to C strings using ``'utf-8' `` encoding.
112115
113- ``z `` (:class:  ` str ` or `` None `` ) [const char  \* ]
114-    Like ``s ``, but the Python object may also be `` None ``, in which case the C 
115-    pointer is set to ``NULL ``.
116-    It is the same as ``s? `` with the C pointer was initialized to ``NULL ``.
116+ ``"z" `` (:ctype:  ` PyUnicodeObject \*  ` or :ctype: ` Py_None ` ) [:ctype: ` const char\*  ` ]
117+    Like ``"s" ``, but the Python object may also be :ctype: ` Py_None `, 
118+    in which case the C  pointer is set to ``NULL ``.
119+    It is the same as ``"s?" `` with the C pointer was initialized to ``NULL ``.
117120
118- ``z* `` (:class: `str `, :term: `bytes-like object ` or ``None ``) [Py_buffer]
119-    Like ``s* ``, but the Python object may also be ``None ``, in which case the
121+ ``"z*" `` (:ctype: `PyUnicodeObject\*  `, :ctype: `PyBytesObject\*  `,
122+           :ctype: `PyByteArrayObject\*  `, :term: `bytes-like object `, or :ctype: `Py_None `)
123+           [:ctype: `Py_buffer `]
124+    Like ``"s*" ``, but the Python object may also be :ctype: `Py_None `, in which case the
120125   ``buf `` member of the :c:type: `Py_buffer ` structure is set to ``NULL ``.
121-    It is the same as ``s*? `` with the ``buf `` member of the :c:type: `Py_buffer `
126+    It is the same as ``" s*?"  `` with the ``buf `` member of the :c:type: `Py_buffer `
122127   structure was initialized to ``NULL ``.
123128
124- ``z# `` (:class: `str `, read-only :term: `bytes-like object ` or ``None ``) [const char \* , :c:type: `Py_ssize_t `]
125-    Like ``s# ``, but the Python object may also be ``None ``, in which case the C
126-    pointer is set to ``NULL ``.
127-    It is the same as ``s#? `` with the C pointer was initialized to ``NULL ``.
129+ ``"z#" `` (:ctype: `PyUnicodeObject\*  `, :ctype: `PyBytesObject\*  `,
130+           read-only :term: `bytes-like object ` or :ctype: `Py_None `)
131+           [:ctype: `const char\*  `, :ctype: `int `]
132+    Like ``"s#" ``, but the Python object may also be :ctype: `Py_None `, in which
133+    case the C pointer is set to ``NULL ``.
134+    It is the same as ``"s#?" `` with the C pointer was initialized to ``NULL ``.
128135
129- ``y `` (read-only :term: `bytes-like object `) [const char \* ]
136+ ``"y" `` (:ctype: `PyBytesObject\*  ` or read-only :term: `bytes-like object `)
137+          [:ctype: `const char\*  `]
130138   This format converts a bytes-like object to a C pointer to a
131139   :ref: `borrowed  <c-arg-borrowed-buffer >` character string;
132140   it does not accept Unicode objects.  The bytes buffer must not
@@ -137,8 +145,9 @@ There are three ways strings and buffers can be converted to C:
137145      Previously, :exc: `TypeError ` was raised when embedded null bytes were
138146      encountered in the bytes buffer.
139147
140- ``y* `` (:term: `bytes-like object `) [Py_buffer]
141-    This variant on ``s* `` doesn't accept Unicode objects, only
148+ ``"y*" `` (:ctype: `PyBytesObject\*  `, :ctype: `PyByteArrayObject\*  `, or
149+           :term: `bytes-like object `) [:ctype: `Py_buffer\*  `]
150+    This variant on ``"s*" `` doesn't accept Unicode objects, only
142151   bytes-like objects.  **This is the recommended way to accept 
143152   binary data. **
144153
0 commit comments