Skip to content

[3.12] gh-107298: Fix C API Buffer documentation (GH-108011). #108048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
and :c:member:`~Py_buffer.suboffsets` MUST be ``NULL``.
The maximum number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`.

.. :c:macro:: PyBUF_MAX_NDIM

The maximum number of dimensions the memory represents.
Exporters MUST respect this limit, consumers of multi-dimensional
buffers SHOULD be able to handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions.
Currently set to 64.

.. c:member:: Py_ssize_t *shape

An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`
Expand Down Expand Up @@ -221,6 +214,17 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
freed when the buffer is released. The consumer MUST NOT alter this
value.


Constants:

.. c:macro:: PyBUF_MAX_NDIM

The maximum number of dimensions the memory represents.
Exporters MUST respect this limit, consumers of multi-dimensional
buffers SHOULD be able to handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions.
Currently set to 64.


.. _buffer-request-types:

Buffer request types
Expand Down Expand Up @@ -444,7 +448,7 @@ Buffer-related functions

Send a request to *exporter* to fill in *view* as specified by *flags*.
If the exporter cannot provide a buffer of the exact type, it MUST raise
:c:data:`PyExc_BufferError`, set ``view->obj`` to ``NULL`` and
:exc:`BufferError`, set ``view->obj`` to ``NULL`` and
return ``-1``.

On success, fill in *view*, set ``view->obj`` to a new reference
Expand Down Expand Up @@ -531,7 +535,7 @@ Buffer-related functions
and :c:macro:`PyBUF_WRITABLE` is set in *flags*.

On success, set ``view->obj`` to a new reference to *exporter* and
return 0. Otherwise, raise :c:data:`PyExc_BufferError`, set
return 0. Otherwise, raise :exc:`BufferError`, set
``view->obj`` to ``NULL`` and return ``-1``;

If this function is used as part of a :ref:`getbufferproc <buffer-structs>`,
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ Buffer Object Structures
Except for point (3), an implementation of this function MUST take these
steps:

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

(2) Fill in the requested fields.
Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# to help avoid merge conflicts.

Doc/c-api/arg.rst
Doc/c-api/buffer.rst
Doc/c-api/datetime.rst
Doc/c-api/descriptor.rst
Doc/c-api/dict.rst
Expand Down