Issue 2692: bytes object wrongly exposes writeable buffer interface (original) (raw)

IIUC, the bytes object should be immutable (in contrast to bytearray). But PyObject_FromWriteBuffer() does not fail.

It seems that the attached patch fixes it; however there are lots of failures in the testsuite with the patch - even 'memoryview(b"abcd")' fails.

Index: stringobject.c

--- stringobject.c (revision 62498) +++ stringobject.c (working copy) @@ -966,7 +966,7 @@ string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags) { return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_SIZE(self), - 0, flags); + 1, flags); }

static PySequenceMethods string_as_sequence = {