[issue15821] PyMemoryView_FromBuffer() behavior change (possible regression)

Alexander Belopolsky report at bugs.python.org
Fri Aug 31 22:40:45 CEST 2012


Alexander Belopolsky added the comment:

On Fri, Aug 31, 2012 at 3:12 PM, Stefan Krah <report at bugs.python.org> wrote:
> Now I'm puzzled: I thought your goal was to preserve the implicit cleanup
> from 3.2, i.e. PyBuffer_Release() is called when the managed buffer is
> deallocated.
>

The issue that I raised in msg169472 above was that
PyMemoryView_FromBuffer() would not copy .obj from Py_buffer structure
to the memoryview.  A related issue is that it looks like
PyObject_GetBuffer() often does not fill .obj either.   I would expect
that PyObject_GetBuffer() would always store a new reference in .obj
to assure that the .buf pointer remains valid until PyBuffer_Release()
is called explicitly.  (I am ignoring the issue of mutable objects
such as lists for the moment.)   PyMemoryView_FromBuffer() in turn
should store an additional reference in its own private copy of
Py_buffer structure.  After PyMemoryView_FromBuffer() returns a
well-behaved program should call PyBuffer_Release() releasing the
first reference and the second reference should be released in
memoryview destructor.  Am I missing something?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15821>
_______________________________________


More information about the Python-bugs-list mailing list