Stefan Behnel <stefan...@behnel.de> wrote:
>     if (PyObject_GetBuffer(base, &mbuf->master, PyBUF_FULL_RO) < 0) {
>         /* mbuf->master.obj must be NULL. */
>         Py_DECREF(mbuf);
>         return NULL;
>     }
> 
>     /* Assume that master.obj is a new reference to base. */
>     assert(mbuf->master.obj == base);


> I'm not saying that this is likely to happen, but I could imagine code that
> wants to use a different object for the cleanup than itself, possibly for
> keeping a certain kind of state when it delivers more than one buffer, or
> for remembering what kind of allocation was used, or ...

I /think/ a different cleanup object would be possible, but memoryview now
has the m.obj attribute that let's you see easily which object the view
actually references. That attribute would then point to the cleanup handler.

Note that the complexity is such that I would have to go through the whole
code again to be *sure* that it's possible.

So I'd rather see that people just don't use such schemes (unless there
is a storm of protest).


The assumption is clearly documented in:

http://docs.python.org/dev/c-api/buffer.html#Py_buffer
http://docs.python.org/dev/c-api/typeobj.html#buffer-object-structures


Since the Py_buffer.obj filed was undocumented in 3.2, I think we're within
out rights to restrict the field to the exporter.


Stefan Krah


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to