From: Antoine Pitrou Date: Sat, 2 Aug 2008 21:58:05 +0000 (+0000) Subject: Preemptively backport the relevant parts of r65420 X-Git-Tag: v2.6b3~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92a624019867885028fe0b326457b461e672eb3b;p=python Preemptively backport the relevant parts of r65420 --- diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index 535e66ac29..044711cad5 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -364,6 +364,9 @@ class StrTest( self.assertRaises(ValueError, format, "", "-") self.assertRaises(ValueError, "{0:=s}".format, '') + def test_buffer_is_readonly(self): + self.assertRaises(TypeError, sys.stdin.readinto, b"") + def test_main(): test_support.run_unittest(StrTest) diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 0d2ceb1b7f..6d53a099f8 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -1329,7 +1329,7 @@ static int 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 = {