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
Docs for BytesIO.getbuffer say that it returns readable and writable view over the buffer of corresponding BytesIO object without copying the contents of this buffer, and that mutating the view updates the buffer it wraps. Should bytesiobuf_getbuffer call unshare_buffer at all in this case, or I am missing something?
Activity
Eclips4 commentedon Oct 22, 2023
cc @serhiy-storchaka as author of
unshare_bufferfunctionchgnrdv commentedon Oct 22, 2023
Docs for
BytesIO.getbuffersay that it returns readable and writable view over the buffer of correspondingBytesIOobject without copying the contents of this buffer, and that mutating the view updates the buffer it wraps. Shouldbytesiobuf_getbuffercallunshare_bufferat all in this case, or I am missing something?pythongh-111174: Fix crash in getbuffer() called repeatedly for empty…
serhiy-storchaka commentedon Oct 23, 2023
The cause is that empty bytes objects are shared across the interpreter. So
Py_REFCNT(self->buf) > 1even for just createdself->bufif it is empty.gh-111174: Fix crash in getbuffer() called repeatedly for empty Bytes…
pythongh-111174: Fix crash in getbuffer() called repeatedly for empty…
pythongh-111174: Fix crash in getbuffer() called repeatedly for empty…
[3.11] gh-111174: Fix crash in getbuffer() called repeatedly for empt…
[3.12] gh-111174: Fix crash in getbuffer() called repeatedly for empt…
Eclips4 commentedon Oct 25, 2023
Thanks Radislav for the report and Serhiy for the fix!
pythongh-111174: Fix crash in getbuffer() called repeatedly for empty…
pythongh-111174: Fix crash in getbuffer() called repeatedly for empty…