[Python-Dev] Wierd buffer "add" behaviour.

Thomas Heller thomas.heller@ion-tof.com
Mon, 16 Oct 2000 11:14:49 +0200


IMHO, the whole buffer interface is weird.

- Only the Buffer_FromObject() function is exposed to the python
level (as buffer()), the other functions are missing. This
means that one could only use the buffer interface in
extension modules. Was this intentional?

- No way a python class can expose the buffer interface

- There is a bug in the buffer interface (which
prevented recently that I could use buffer objects
at all, I had to implement my own)

PyObject *base = PyBuffer_New(100);
PyObject *buffer = PyBuffer_FromObject(base, 0, 100);
Py_DECREF(base);

After this code is executed,
buffer points to deallocated memory (because
buffer does not hold a reference to base anymore).

(Guido classified this as a wish, but at least
it contradicts the documentation)

Thomas