A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-March/117222.html below:

[Python-Dev] Assertion in _PyManagedBuffer_FromObject()

[Python-Dev] Assertion in _PyManagedBuffer_FromObject() [Python-Dev] Assertion in _PyManagedBuffer_FromObject()Stefan Krah stefan at bytereef.org
Fri Mar 2 12:53:11 CET 2012
Stefan Behnel <stefan_ml at 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


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4