8000 [3.13] gh-123609: Clarify usage of standalone `PyBUF_FORMAT` (GH-1237… · python/cpython@ed69247 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed69247

Browse files
[3.13] gh-123609: Clarify usage of standalone PyBUF_FORMAT (GH-123778) (#123903)
gh-123609: Clarify usage of standalone `PyBUF_FORMAT` (GH-123778) (cherry picked from commit 962304a) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
1 parent 857a161 commit ed69247

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/c-api/buffer.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ The following fields are not influenced by *flags* and must always be filled in
244244
with the correct values: :c:member:`~Py_buffer.obj`, :c:member:`~Py_buffer.buf`,
245245
:c:member:`~Py_buffer.len`, :c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`.
246246

247-
248247
readonly, format
249248
~~~~~~~~~~~~~~~~
250249

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

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

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

271272

272273
shape, strides, suboffsets

0 commit comments

Comments
 (0)
0