[issue10616] Change PyObject_AsCharBuffer() error message
Sijin Joseph
report at bugs.python.org
Mon Apr 25 17:17:08 CEST 2011
Sijin Joseph <sijinjoseph at gmail.com> added the comment:
Looking at object.h the buffer interface is defined as
/* buffer interface */
typedef struct bufferinfo {
void *buf;
PyObject *obj; /* owned reference */
Py_ssize_t len;
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
pointed to by strides in simple case.*/
int readonly;
int ndim;
char *format;
Py_ssize_t *shape;
Py_ssize_t *strides;
Py_ssize_t *suboffsets;
Py_ssize_t smalltable[2]; /* static store for shape and strides of
mono-dimensional buffers. */
void *internal;
} Py_buffer;
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
typedef struct {
getbufferproc bf_getbuffer;
releasebufferproc bf_releasebuffer;
} PyBufferProcs;
The code that's throwing that error looks like
if (pb == NULL || pb->bf_getbuffer == NULL) {
PyErr_SetString(PyExc_TypeError,
"expected an object with the buffer interface");
I would argue that the error message gives appropriate information because it is expecting the object to have a bf_getbuffer member.
Maybe the friendly error message is best handled at a higher level?
----------
nosy: +sijinjoseph
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10616>
_______________________________________
More information about the Python-bugs-list
mailing list