[pypy-issue] Issue #3130: [cpyext] internal field of buffer struct lost or ignored (pypy/pypy)
issues-reply at bitbucket.org
Wed Dec 18 17:25:00 EST 2019
New issue 3130: [cpyext] internal field of buffer struct lost or ignored
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.
More information about the pypy-issue