Skip to content

Commit c2941cb

Browse files
authored
gh-107298: Fix C API Buffer documentation (#108011)
1 parent f2a9dfd commit c2941cb

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

Doc/c-api/buffer.rst

+13-9
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
163163
and :c:member:`~Py_buffer.suboffsets` MUST be ``NULL``.
164164
The maximum number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`.
165165

166-
.. :c:macro:: PyBUF_MAX_NDIM
167-
168-
The maximum number of dimensions the memory represents.
169-
Exporters MUST respect this limit, consumers of multi-dimensional
170-
buffers SHOULD be able to handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions.
171-
Currently set to 64.
172-
173166
.. c:member:: Py_ssize_t *shape
174167
175168
An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`
@@ -221,6 +214,17 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
221214
freed when the buffer is released. The consumer MUST NOT alter this
222215
value.
223216

217+
218+
Constants:
219+
220+
.. c:macro:: PyBUF_MAX_NDIM
221+
222+
The maximum number of dimensions the memory represents.
223+
Exporters MUST respect this limit, consumers of multi-dimensional
224+
buffers SHOULD be able to handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions.
225+
Currently set to 64.
226+
227+
224228
.. _buffer-request-types:
225229

226230
Buffer request types
@@ -444,7 +448,7 @@ Buffer-related functions
444448
445449
Send a request to *exporter* to fill in *view* as specified by *flags*.
446450
If the exporter cannot provide a buffer of the exact type, it MUST raise
447-
:c:data:`PyExc_BufferError`, set ``view->obj`` to ``NULL`` and
451+
:exc:`BufferError`, set ``view->obj`` to ``NULL`` and
448452
return ``-1``.
449453
450454
On success, fill in *view*, set ``view->obj`` to a new reference
@@ -531,7 +535,7 @@ Buffer-related functions
531535
and :c:macro:`PyBUF_WRITABLE` is set in *flags*.
532536
533537
On success, set ``view->obj`` to a new reference to *exporter* and
534-
return 0. Otherwise, raise :c:data:`PyExc_BufferError`, set
538+
return 0. Otherwise, raise :exc:`BufferError`, set
535539
``view->obj`` to ``NULL`` and return ``-1``;
536540
537541
If this function is used as part of a :ref:`getbufferproc <buffer-structs>`,

Doc/c-api/typeobj.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ Buffer Object Structures
24432443
Except for point (3), an implementation of this function MUST take these
24442444
steps:
24452445

2446-
(1) Check if the request can be met. If not, raise :c:data:`PyExc_BufferError`,
2446+
(1) Check if the request can be met. If not, raise :exc:`BufferError`,
24472447
set :c:expr:`view->obj` to ``NULL`` and return ``-1``.
24482448

24492449
(2) Fill in the requested fields.

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# as tested on the CI via check-warnings.py in reusable-docs.yml.
33
# Keep lines sorted lexicographically to help avoid merge conflicts.
44

5-
Doc/c-api/buffer.rst
65
Doc/c-api/datetime.rst
76
Doc/c-api/descriptor.rst
87
Doc/c-api/exceptions.rst

0 commit comments

Comments
 (0)