New issue 3130: [cpyext] internal field of buffer struct lost or ignored
https://bitbucket.org/pypy/pypy/issues/3130/cpyext-internal-field-of-buffer-struct

nlgranger:

When creating an object exposing the buffer protocol, the python specification 
offers an 
\[internal\]\([https://docs.python.org/3/c-api/buffer.html#c.Py\_buffer.internal](https://docs.python.org/3/c-api/buffer.html#c.Py_buffer.internal)\)
 field in the buffer struct to store custom values. This field is incorrectly 
set to NULL when 
\[releasebuffer\]\([https://docs.python.org/3/c-api/typeobj.html?highlight=releasebuffer#c.PyBufferProcs.bf\_releasebuffer](https://docs.python.org/3/c-api/typeobj.html?highlight=releasebuffer#c.PyBufferProcs.bf_releasebuffer)\)
 is called instead of keeping the value it was initially assigned. Presumable, 
PyPy didn’t even read that value.

In the attached example, the internal field is read back by 
RefCountedBuffer\_releasebuffer when a buffer gets released in mymodule.c l118. 
The example is a wrapper around objects already exposing the buffer API, it 
adds a refcount to track how many views of the buffer exist and triggers a 
callback when that count reaches 0.


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to