Skip to content
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

PyObject_AsWriteBuffer is removed from CPython in 3.10 #190

Closed
tacaswell opened this issue Jun 29, 2020 · 4 comments · Fixed by #202 · May be fixed by freepn/freepn-gtk3-tray#14
Closed

PyObject_AsWriteBuffer is removed from CPython in 3.10 #190

tacaswell opened this issue Jun 29, 2020 · 4 comments · Fixed by #202 · May be fixed by freepn/freepn-gtk3-tray#14
Assignees
Labels

Comments

@tacaswell
Copy link

See https://github.com/python/cpython/blob/e4f1fe6edb216e04da03ae80b462ca273f00255b/Doc/whatsnew/3.10.rst#removed-1

It looks like PyObject_AsWriteBuffer is currently a wrapper around the new API (https://docs.python.org/3/c-api/objbuffer.html?highlight=pyobject_aswritebuffer#c.PyObject_AsWriteBuffer).

It looks like pycairo uses this function in one place (and wraps it to suppress the deprecation warnings)

pycairo/cairo/surface.c

Lines 823 to 825 in f0c0e5a

PYCAIRO_BEGIN_IGNORE_DEPRECATED
res = PyObject_AsWriteBuffer (obj, (void **)&buffer, &buffer_len);
PYCAIRO_END_IGNORE_DEPRECATED

Unfortunately I do not have time right now to dig into this and offer a fix.

@lazka
Copy link
Member

lazka commented Jun 29, 2020

3.10 will become an issue once it hits beta 2021-05-03 (https://www.python.org/dev/peps/pep-0619/) so not that pressing. But thanks for bringing it up!

My first try would be to just see what PyObject_AsWriteBuffer does internally and see it it's viable to replicate that.

Here is the PR removing it from CPython: python/cpython#21117

@lazka lazka added the bug label Jun 29, 2020
@sarnold
Copy link

sarnold commented Jun 29, 2020

This is hitting me now in travis-ci in the Python: nightly build. Hopefully I will notice the github notifies later...

@lazka
Copy link
Member

lazka commented Jun 30, 2020

ok, if it affects people today we should try to look into it.

@lazka lazka self-assigned this Jul 4, 2020
lazka added a commit to lazka/pycairo that referenced this issue Sep 2, 2020
PyObject_AsWriteBuffer() is removed in Python 3.10. Port things to use
PyObject_GetBuffer() and PyBuffer_Release() instead.

This does more or less the same, but instead of keeping the object which provides
the buffer alive we now keep the buffer itself alive, which in turn keeps a reference
on the exporting object.

See pygobject#190
@lazka
Copy link
Member

lazka commented Sep 5, 2020

PyObject_AsWriteBuffer is gone in master, PyObject_AsReadBuffer still needs to be removed.

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