[Python-Dev] Py_buffer.obj documentation

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Aug 29 23:28:29 CEST 2012


I am trying to reconcile this section in 3.3 documentation:

"""
void *obj

A new reference to the exporting object. The reference is owned by the
consumer and automatically decremented and set to NULL by
PyBuffer_Release(). The field is the equivalent of the return value of
any standard C-API function.

As a special case, for temporary buffers that are wrapped by
PyMemoryView_FromBuffer() or PyBuffer_FillInfo() this field is NULL.
In general, exporting objects MUST NOT use this scheme.
""" -- http://docs.python.org/dev/c-api/buffer.html#Py_buffer.obj

with the following comment in the code (Objects/memoryobject.c:762):

    /* info->obj is either NULL or a borrowed reference. This
reference
       should not be decremented in PyBuffer_Release(). */

I have not studied the code yet, but given the history of bugs in this
area the code may not have the most authoritative answer.  In any
case, either the comment or the ReST section should be corrected.


More information about the Python-Dev mailing list