Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 9305:083efa076366 legacy-trunk
Greg Stein: Implement the new bf_getcharbuffer function, indicating
that (as far as the data type is concerned!) this is character data.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 08 Oct 1998 02:18:52 +0000 |
| parents | 4fe8a7670c0d |
| children | 8234bb36fb8c |
line wrap: on
line diff
--- a/Objects/stringobject.c Thu Oct 08 02:10:56 1998 +0000 +++ b/Objects/stringobject.c Thu Oct 08 02:18:52 1998 +0000 @@ -465,7 +465,7 @@ { if ( index != 0 ) { PyErr_SetString(PyExc_SystemError, - "Accessing non-existent string segment"); + "accessing non-existent string segment"); return -1; } *ptr = (void *)self->ob_sval; @@ -493,6 +493,21 @@ 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*/ @@ -507,6 +522,7 @@ (getreadbufferproc)string_buffer_getreadbuf, (getwritebufferproc)string_buffer_getwritebuf, (getsegcountproc)string_buffer_getsegcount, + (getcharbufferproc)string_buffer_getcharbuf, }; PyTypeObject PyString_Type = { @@ -530,7 +546,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &string_as_buffer, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ };
