-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-107298: Fix C API Buffer documentation #108011
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` | ||
|
@@ -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 | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is yet one reference in typeobj.rst. |
||
return ``-1``. | ||
|
||
On success, fill in *view*, set ``view->obj`` to a new reference | ||
|
@@ -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>`, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just add
here, and restore the namespace after the description to fix reference issues.
I already used it for some macros declared not at the top level.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#namespacing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw your "namespace: NULL" trick of your other PRs, but here Py_buffer members are defined before and after this macro which is not part of Py_buffer structure. In terms of Sphinx, it's confusing. I prefer to document it somewhere else.