@@ -32,42 +32,46 @@ variable(s) whose address should be passed.
3232 converted to C strings using the default encoding. If this conversion fails, a
3333 :exc: `UnicodeError ` is raised.
3434
35- ``s# `` (string, Unicode or any read buffer compatible object) [const char \* , int]
36- This variant on ``s `` stores into two C variables, the first one a pointer to a
37- character string, the second one its length. In this case the Python string may
38- contain embedded null bytes. Unicode objects pass back a pointer to the default
39- encoded string version of the object if such a conversion is possible. All
40- other read-buffer compatible objects pass back a reference to the raw internal
41- data representation.
42-
4335``s* `` (string, Unicode, or any buffer compatible object) [Py_buffer \* ]
44- Similar to ``s# ``, this code fills a Py_buffer structure provided by the caller.
45- The buffer gets locked, so that the caller can subsequently use the buffer even
46- inside a ``Py_BEGIN_ALLOW_THREADS `` block; the caller is responsible for calling
47- ``PyBuffer_Release `` with the structure after it has processed the data.
36+ This is similar to ``s ``, but the code fills a :ctype: `Py_buffer ` structure
37+ provided by the caller. In this case the Python string may contain embedded
38+ null bytes. Unicode objects pass back a pointer to the default encoded
39+ string version of the object if such a conversion is possible. The
40+ underlying buffer is locked, so that the caller can subsequently use the
41+ buffer even inside a ``Py_BEGIN_ALLOW_THREADS `` block. **The caller is
42+ responsible ** for calling ``PyBuffer_Release `` with the structure after it
43+ has processed the data.
4844
49- ``y `` (bytes object) [const char \* ]
50- This variant on ``s `` convert a Python bytes object to a C pointer to a
51- character string. The bytes object must not contain embedded NUL bytes; if it
52- does, a :exc: `TypeError ` exception is raised.
45+ ``s# `` (string, Unicode or any read buffer compatible object) [const char \* , int]
46+ This variant on ``s* `` stores into two C variables, the first one a pointer
47+ to a character string, the second one its length. All other read-buffer
48+ compatible objects pass back a reference to the raw internal data
49+ representation. Since this format doesn't allow writable buffer compatible
50+ objects like byte arrays, ``s* `` is to be preferred.
5351
54- ``y# `` (bytes object) [const char \* , int]
55- This variant on ``s# `` stores into two C variables, the first one a pointer to a
56- character string, the second one its length. This only accepts bytes objects.
52+ ``y `` (bytes object) [const char \* ]
53+ This variant on ``s `` converts a Python bytes or bytearray object to a C
54+ pointer to a character string. The bytes object must not contain embedded
55+ NUL bytes; if it does, a :exc: `TypeError ` exception is raised.
5756
5857``y* `` (bytes object) [Py_buffer \* ]
5958 This is to ``s* `` as ``y `` is to ``s ``.
6059
60+ ``y# `` (bytes object) [const char \* , int]
61+ This variant on ``s# `` stores into two C variables, the first one a pointer
62+ to a character string, the second one its length. This only accepts bytes
63+ objects, no byte arrays.
64+
6165``z `` (string or ``None ``) [const char \* ]
6266 Like ``s ``, but the Python object may also be ``None ``, in which case the C
6367 pointer is set to *NULL *.
6468
65- ``z# `` (string or ``None `` or any read buffer compatible object) [const char \* , int]
66- This is to ``s# `` as ``z `` is to ``s ``.
67-
6869``z* `` (string or ``None `` or any buffer compatible object) [Py_buffer*]
6970 This is to ``s* `` as ``z `` is to ``s ``.
7071
72+ ``z# `` (string or ``None `` or any read buffer compatible object) [const char \* , int]
73+ This is to ``s# `` as ``z `` is to ``s ``.
74+
7175``u `` (Unicode object) [Py_UNICODE \* ]
7276 Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
7377 16-bit Unicode (UTF-16) data. As with ``s ``, there is no need to provide
@@ -249,16 +253,16 @@ variable(s) whose address should be passed.
249253 or use ``w# `` instead. Only single-segment buffer objects are accepted;
250254 :exc: `TypeError ` is raised for all others.
251255
256+ ``w* `` (read-write byte-oriented buffer) [Py_buffer \* ]
257+ This is to ``w `` what ``s* `` is to ``s ``.
258+
252259``w# `` (read-write character buffer) [char \* , int]
253260 Like ``s# ``, but accepts any object which implements the read-write buffer
254261 interface. The :ctype: `char \* ` variable is set to point to the first byte of
255262 the buffer, and the :ctype: `int ` is set to the length of the buffer. Only
256263 single-segment buffer objects are accepted; :exc: `TypeError ` is raised for all
257264 others.
258265
259- ``w* `` (read-write byte-oriented buffer) [Py_buffer \* ]
260- This is to ``w `` what ``s* `` is to ``s ``.
261-
262266``(items) `` (tuple) [*matching-items *]
263267 The object must be a Python sequence whose length is the number of format units
264268 in *items *. The C arguments must correspond to the individual format units in
0 commit comments