You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These should be removed from the *limited API*, but stay for the stable ABI.
(PEP-652 mentions this can happen but doesn't give details, which will be a bit tricky. These are good candidates for figuring out the process.)
I assigned this to myself; I'll try to get to it for 3.11.
What is the benefit of removing this? Is copy pasting the compatibility layer to (possibly many) different projects worth the "cleanup"?
Yes. PyObject_AsReadBuffer is dangerous *in general*, but in certain specific cases where you're relying on CPython implementations details it can work. For example, borrowing a buffer from a *string* or *array* will work on CPython, and I don't see that changing any time soon. So, using PyObject_AsReadBuffer is still tech debt, but for some projects that's OK.
All this should be documented in the release notes, though, so the projects know what they're doing. (And the release notes should be written *with the change*, not later, so projects testing early can read them.)
I closed my issue #105186 as a duplicate of this one. Copy of my message.
Would it be ok to remove the legacy "buffer" API in Python 3.13, scheduled for October 2024? I'm talking about functions:
PyObject_AsCharBuffer()
PyObject_CheckReadBuffer()
PyObject_AsReadBuffer()
PyObject_AsWriteBuffer()
This API is deprecated since Python 3.0 and is older than the new Py_buffer API. The Py_buffer API is safer: it has a PyBuffer_Release() method to notify when the consumer is done: the resource can be released. The Py_buffer API is now commonly used.
In June 2020, there was a first attempt to remove these functions in issue #85275: commit 6f8a6ee. It caused too many troubles and had to be reverted the following year (commit ce5e1a6, July 2021). The removed functions were still used by at least 6 projects:
PyQt4: FIXED in PyQt5 by using the safe PyObject_GetBuffer()/PyBuffer_Release() functions. PyQt4 is now legacy.
Sadly, the 4 functions are part of the stable ABI and have to be kept there. I'm only asking to remove them in the C API. The issue #88775 was complaining that the functions were removed wheareas they are part of the stable ABI.
Activity
ambv commentedon Jul 29, 2021
New changeset ce5e1a6 by Inada Naoki in branch 'main':
bpo-41103: Resurrect the old buffer protocol. (GH-27437)
ce5e1a6
ambv commentedon Jul 29, 2021
New changeset 6b922da by Miss Islington (bot) in branch '3.10':
bpo-41103: Resurrect the old buffer protocol. (GH-27437) (GH-27441)
6b922da
ambv commentedon Jul 30, 2021
Resolved as "wontfix" due to presence in the stable ABI.
encukou commentedon Aug 5, 2021
These should be removed from the *limited API*, but stay for the stable ABI.
(PEP-652 mentions this can happen but doesn't give details, which will be a bit tricky. These are good candidates for figuring out the process.)
I assigned this to myself; I'll try to get to it for 3.11.
Yes. PyObject_AsReadBuffer is dangerous *in general*, but in certain specific cases where you're relying on CPython implementations details it can work. For example, borrowing a buffer from a *string* or *array* will work on CPython, and I don't see that changing any time soon. So, using PyObject_AsReadBuffer is still tech debt, but for some projects that's OK.
All this should be documented in the release notes, though, so the projects know what they're doing. (And the release notes should be written *with the change*, not later, so projects testing early can read them.)
vstinner commentedon Jun 1, 2023
I closed my issue #105186 as a duplicate of this one. Copy of my message.
Would it be ok to remove the legacy "buffer" API in Python 3.13, scheduled for October 2024? I'm talking about functions:
This API is deprecated since Python 3.0 and is older than the new
Py_bufferAPI. ThePy_bufferAPI is safer: it has a PyBuffer_Release() method to notify when the consumer is done: the resource can be released. ThePy_bufferAPI is now commonly used.In June 2020, there was a first attempt to remove these functions in issue #85275: commit 6f8a6ee. It caused too many troubles and had to be reverted the following year (commit ce5e1a6, July 2021). The removed functions were still used by at least 6 projects:
The webassets project was also mentioned, but I'm not sure that its failure is related to these removal: see https://bugzilla.redhat.com/show_bug.cgi?id=1899555 I cannot find these functions in https://github.com/Kronuz/pyScss code right now.
Sadly, the 4 functions are part of the stable ABI and have to be kept there. I'm only asking to remove them in the C API. The issue #88775 was complaining that the functions were removed wheareas they are part of the stable ABI.
encukou commentedon Jun 1, 2023
Sorry I didn't get to this.
Removing them from public API, including the limited API, is AFAIK fine. But
Please keep (or add) tests for them, so they don't regress.
vstinner commentedon Jun 1, 2023
I propose to only remove them in the C API, but still export them in the stable ABI. That's what @methane's PR #105137 does.
gh-85275: Remove old buffer APIs (#105137)
Python 3.13 removed the old buffer interface
Python 3.13 removed the old buffer interface
Python 3.13 removed the old buffer interface
Python 3.13 removed the old buffer interface
Python 3.13 removed the old buffer interface