Skip to content

Commit

Permalink
pythongh-123609: Clarify usage of standalone PyBUF_FORMAT (pythonGH…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Sep 10, 2024
1 parent fb1b51a commit 962304a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ The following fields are not influenced by *flags* and must always be filled in
with the correct values: :c:member:`~Py_buffer.obj`, :c:member:`~Py_buffer.buf`,
:c:member:`~Py_buffer.len`, :c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`.


readonly, format
~~~~~~~~~~~~~~~~

Expand All @@ -253,7 +252,8 @@ readonly, format
Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter
MUST provide a writable buffer or else report failure. Otherwise, the
exporter MAY provide either a read-only or writable buffer, but the choice
MUST be consistent for all consumers.
MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | PyBUF_WRITABLE`
can be used to request a simple writable buffer.

.. c:macro:: PyBUF_FORMAT
Expand All @@ -265,8 +265,9 @@ readonly, format
Since :c:macro:`PyBUF_SIMPLE` is defined as 0, :c:macro:`PyBUF_WRITABLE`
can be used as a stand-alone flag to request a simple writable buffer.

:c:macro:`PyBUF_FORMAT` can be \|'d to any of the flags except :c:macro:`PyBUF_SIMPLE`.
The latter already implies format ``B`` (unsigned bytes).
:c:macro:`PyBUF_FORMAT` must be \|'d to any of the flags except :c:macro:`PyBUF_SIMPLE`, because
the latter already implies format ``B`` (unsigned bytes). :c:macro:`!PyBUF_FORMAT` cannot be
used on its own.


shape, strides, suboffsets
Expand Down

0 comments on commit 962304a

Please sign in to comment.