Hi, while implementing Py_buffer support in Cython, I noticed (the hard way, throught a segfault), that the buffer pointer passed into getbuffer() can be NULL, e.g. when calling memoryview.tobytes(). According to PEP 3118 (first paragraph below the getbuffer() signature), this implies setting a lock on the memory. Funny enough, the LOCK flag wasn't even set in my case, I just get NULL as buffer and 285 as flags...
Anyway, my point is that this part of the protocol actually implies setting a lock on the buffer *provider* rather than the buffer itself, as the buffer provider cannot distinguish between different buffers based on a NULL pointer. I know, the protocol is overly complex already and hard to implement from a provider perspective, and I understand that that was preferred over putting the complexity into the consumer. But wouldn't it make more sense to *always* pass the buffer pointer, to let the provider decide what it makes of the flags? I can well imagine the case where a buffer provider chooses to return different buffer pointers based on the WRITABLE flag, for example. In that case, it would be unable to attribute the lock to any of the buffers. Stefan _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com