[Cython] On GetBuffer/ReleaseBuffer (attn: Stefan)

Stefan Behnel stefan_ml at behnel.de
Tue Jul 29 19:48:18 CEST 2008


Hi,

Dag Sverre Seljebotn wrote:
> First, Stefan: In tests/run/buffer.pyx I saw references to "obj == NULL" 
> for locking the buffer. I can't seem find any references to this 
> anywhere, any hints?

Ah, yes, that's a left-over from the original buffer proposal as implemented
before 3.0 beta. I specifically pushed for a change here (and I'm very happy I
started implementing this in time). In the resulting discussion, Greg finally
got Trevis convinced that read/write locking was too complex a thing to
include in the basic buffer protocol API.

The fact that the test is still passing isn't a good sign, though. The
implementation in Py3 is still not finished, and they're getting close to the
last beta release.


> PyAPI_FUNC(void) PyObject_ReleaseBuffer(PyObject *obj, Py_buffer *view);
> 
> Actually, it says in the PEP that the function "always succeeds". But I 
> would guess that we don't actually enforce that for Cython-implemented 
> __releasebuffer__? So ideally one would raise a compiler error if there 
> was a chance that an exception would be propagated from ReleaseBuffer 
> (much like Java does for some exceptions)...

I would prefer a visible compiler warning *whenever* we generate a
"writeUnraisable()", not only for a buffer case, as "errors should never pass
silently, unless explicitly silenced". I'm against an error, though. If
someone wants to ignore the warning, we'd still end up with valid code.

Stefan


More information about the Cython-dev mailing list