@@ -113,14 +113,18 @@ There are three ways strings and buffers can be converted to C:
113113``z `` (:class: `str ` or ``None ``) [const char \* ]
114114 Like ``s ``, but the Python object may also be ``None ``, in which case the C
115115 pointer is set to ``NULL ``.
116+ It is the same as ``s? `` with the C pointer was initialized to ``NULL ``.
116117
117118``z* `` (:class: `str `, :term: `bytes-like object ` or ``None ``) [Py_buffer]
118119 Like ``s* ``, but the Python object may also be ``None ``, in which case the
119120 ``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 `
122+ structure was initialized to ``NULL ``.
120123
121124``z# `` (:class: `str `, read-only :term: `bytes-like object ` or ``None ``) [const char \* , :c:type: `Py_ssize_t `]
122125 Like ``s# ``, but the Python object may also be ``None ``, in which case the C
123126 pointer is set to ``NULL ``.
127+ It is the same as ``s#? `` with the C pointer was initialized to ``NULL ``.
124128
125129``y `` (read-only :term: `bytes-like object `) [const char \* ]
126130 This format converts a bytes-like object to a C pointer to a
@@ -357,11 +361,37 @@ Other objects
357361
358362 .. versionadded :: 3.3
359363
360- ``(items) `` (:class: `tuple `) [*matching-items *]
361- The object must be a Python sequence whose length is the number of format units
364+ ``(items) `` (sequence) [*matching-items *]
365+ The object must be a Python sequence (except :class: `str `, :class: `bytes `
366+ or :class: `bytearray `) whose length is the number of format units
362367 in *items *. The C arguments must correspond to the individual format units in
363368 *items *. Format units for sequences may be nested.
364369
370+ If *items * contains format units which store a :ref: `borrowed buffer
371+ <c-arg-borrowed-buffer>` (``s ``, ``s# ``, ``z ``, ``z# ``, ``y ``, or ``y# ``)
372+ or a :term: `borrowed reference ` (``S ``, ``Y ``, ``U ``, ``O ``, or ``O! ``),
373+ the object must be a Python tuple.
374+ The *converter * for the ``O& `` format unit in *items * must not store
375+ a borrowed buffer or a borrowed reference.
376+
377+ .. versionchanged :: next
378+ :class: `str ` and :class: `bytearray ` objects no longer accepted as a sequence.
379+
380+ .. deprecated :: next
381+ Non-tuple sequences are deprecated if *items * contains format units
382+ which store a borrowed buffer or a borrowed reference.
383+
384+ ``unit? `` (anything or ``None ``) [*matching-variable(s) *]
385+ ``? `` modifies the behavior of the preceding format unit.
386+ The C variable(s) corresponding to that parameter should be initialized
387+ to their default value --- when the argument is ``None ``,
388+ :c:func: `PyArg_ParseTuple ` does not touch the contents of the corresponding
389+ C variable(s).
390+ If the argument is not ``None ``, it is parsed according to the specified
391+ format unit.
392+
393+ .. versionadded :: next
394+
365395A few other characters have a meaning in a format string. These may not occur
366396inside nested parentheses. They are:
367397
0 commit comments