classification
Title: Removing old buffer support
Type: Stage: resolved
Components: C API Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: hroncok, methane, vstinner
Priority: normal Keywords: patch

Created on 2020-06-24 13:43 by methane, last changed 2020-11-26 02:35 by methane. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21117 merged methane, 2020-06-24 13:58
Messages (5)
msg372251 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-06-24 13:43
https://docs.python.org/3/c-api/objbuffer.html
Old buffer protocol has been deprecated since Python 3.0.
It was useful to make transition from Python 2 easy.
But it's time to remove.
msg372391 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-06-25 23:07
New changeset 6f8a6ee59cb7f99f68df8ee9c3e8c8cf19af3eed by Inada Naoki in branch 'master':
bpo-41103: Remove old buffer protocol support (#21117)
https://github.com/python/cpython/commit/6f8a6ee59cb7f99f68df8ee9c3e8c8cf19af3eed
msg381854 - (view) Author: Miro HronĨok (hroncok) * Date: 2020-11-25 17:22
I've just seen a fix of PyQt4 that basically copy pastes (some of) the removed code to PyQt4:

https://src.fedoraproject.org/rpms/PyQt4/pull-request/2#request_diff

What is the benefit of removing this? Is copy pasting the compatibility layer to (possibly many) different projects worth the "cleanup"?

In Fedora, at least 7 packages are broken so far:

PyQt4: https://bugzilla.redhat.com/show_bug.cgi?id=1895298
libsolv: https://bugzilla.redhat.com/show_bug.cgi?id=1896411
m2crypto: https://bugzilla.redhat.com/show_bug.cgi?id=1897148
apsw: https://bugzilla.redhat.com/show_bug.cgi?id=1897500
djvulibre: https://bugzilla.redhat.com/show_bug.cgi?id=1897558
wsaccel: https://bugzilla.redhat.com/show_bug.cgi?id=1899550
webassets: https://bugzilla.redhat.com/show_bug.cgi?id=1899555
msg381865 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-11-25 21:24
PyObject_AsCharBuffer() is dangerous: it returns a dangling pointer by design. PyObject_GetBuffer() design is safer: the API ensures that the buffer remains valid until PyBuffer_Release() is called.

PyQt5 was updated to use the safe PyObject_GetBuffer()/PyBuffer_Release(). PyQt4 is no longer updated, that's why I proposed a downstream fix which copy/paste the old code. Changing PyQt4 to use the safe API was not worth it, since it's complex to redesign the impacted function qpycore_encode().
msg381873 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-11-26 02:35
Thank you for reporting. I removed these APIs to get such feedback as early as possible.

We are free to revive these APIs if it breaks too much and some projects can not be fixed before Python 3.10 release.

Some project maintainers ignore deprecations and wait compile errors to fix soemthing. (e.g. https://github.com/rogerbinns/apsw/issues/288#issuecomment-644442322)
That's why we need to break some projects during alpha phase.


> What is the benefit of removing this? Is copy pasting the compatibility layer to (possibly many) different projects worth the "cleanup"?

Oh, no need to copy-paste compatibility layer for all projects. They can migrate to new APIs.
History
Date User Action Args
2020-11-26 02:35:36methanesetmessages: + msg381873
2020-11-25 21:24:44vstinnersetmessages: + msg381865
2020-11-25 17:22:55hroncoksetnosy: + vstinner, hroncok
messages: + msg381854
2020-06-25 23:07:42methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-25 23:07:28methanesetmessages: + msg372391
2020-06-24 13:58:20methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request20280
2020-06-24 13:43:42methanecreate