This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bytes object wrongly exposes writeable buffer interface
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: theller
Priority: normal Keywords:

Created on 2008-04-25 17:14 by theller, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg65796 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-04-25 17:14
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 = {
msg66012 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-04-30 17:39
Duplicate of issue #2538.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46944
2008-04-30 17:39:04thellersetstatus: open -> closed
resolution: duplicate
messages: + msg66012
2008-04-25 20:45:45benjamin.petersonsettype: behavior
2008-04-25 17:14:47thellercreate