Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-85275: Remove old buffer APIs #105137

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 7 commits into from
Jun 2, 2023

Conversation

methane
Copy link
Member

@methane methane commented May 31, 2023

They are now ABI only.


📚 Documentation preview 📚: https://cpython-previews--105137.org.readthedocs.build/


* ``PyObject_AsCharBuffer()``, ``PyObject_AsReadBuffer()``, ``PyObject_CheckReadBuffer()``,
and ``PyObject_AsWriteBuffer()`` are removed. Please migrate to new buffer protocol;
:c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to elaborate how to replace the 3 "As" functions with PyObject_GetBuffer() flags? I'm not used this Py_buffer API. AsCharBuffer() use const char ** type and AsReadBuffer() use const void **buffer type: constant. But PyBuffer.buf type is void*, it's mutable. Maybe add a note about casting if needed? Or provide a full recipe. I don't know.

How do you replace buffer_len? Is it Py_buffer.len or Py_buffer.itemsize? It's a honest question, I don't know the answer :-(

You may also mention that PyObject_CheckReadBuffer() ignores any kind of exception, whereas PyObject_GetBuffer() can raise different exceptions. What is the expected exception if a type doesn't support the buffer protocol?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks. Let's try again to remove them in Python 3.13.

Co-authored-by: Victor Stinner <[email protected]>
@methane methane enabled auto-merge (squash) June 2, 2023 00:49
@methane methane merged commit 37498fc into python:main Jun 2, 2023
@methane methane deleted the remove-old-buffer-protocol branch June 2, 2023 01:12
@vstinner
Copy link
Member

vstinner commented Jun 3, 2023

Nice. Let's see how it goes now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants