{
if ( idx != 0 ) {
PyErr_SetString(PyExc_SystemError,
- "Accessing non-existent buffer segment");
+ "accessing non-existent buffer segment");
return -1;
}
*pp = self->b_ptr;
return 1;
}
+static int
+buffer_getcharbuf(self, idx, pp)
+ PyBufferObject *self;
+ int idx;
+ const char ** pp;
+{
+ if ( idx != 0 ) {
+ PyErr_SetString(PyExc_SystemError,
+ "accessing non-existent buffer segment");
+ return -1;
+ }
+ *pp = (const char *)self->b_ptr;
+ return self->b_size;
+}
+
static PySequenceMethods buffer_as_sequence = {
(inquiry)buffer_length, /*sq_length*/
(getreadbufferproc)buffer_getreadbuf,
(getwritebufferproc)buffer_getwritebuf,
(getsegcountproc)buffer_getsegcount,
+ (getcharbufferproc)buffer_getcharbuf,
};
PyTypeObject PyBuffer_Type = {
0, /*tp_getattro*/
0, /*tp_setattro*/
&buffer_as_buffer, /*tp_as_buffer*/
- 0, /*tp_xxx4*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
};
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
- "Accessing non-existent string segment");
+ "accessing non-existent string segment");
return -1;
}
*ptr = (void *)self->ob_sval;
return 1;
}
+static int
+string_buffer_getcharbuf(self, index, ptr)
+ PyStringObject *self;
+ int index;
+ const char **ptr;
+{
+ if ( index != 0 ) {
+ PyErr_SetString(PyExc_SystemError,
+ "accessing non-existent string segment");
+ return -1;
+ }
+ *ptr = self->ob_sval;
+ return self->ob_size;
+}
+
static PySequenceMethods string_as_sequence = {
(inquiry)string_length, /*sq_length*/
(binaryfunc)string_concat, /*sq_concat*/
(getreadbufferproc)string_buffer_getreadbuf,
(getwritebufferproc)string_buffer_getwritebuf,
(getsegcountproc)string_buffer_getsegcount,
+ (getcharbufferproc)string_buffer_getcharbuf,
};
PyTypeObject PyString_Type = {
0, /*tp_getattro*/
0, /*tp_setattro*/
&string_as_buffer, /*tp_as_buffer*/
- 0, /*tp_xxx4*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
};