Issue #10750: The `raw` attribute of buffered IO objects is now read-only.
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index a17fcee..ee4e42f 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -730,6 +730,13 @@
self.assertRaises(self.UnsupportedOperation, bufio.tell)
self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+ def test_readonly_attributes(self):
+ raw = self.MockRawIO()
+ buf = self.tp(raw)
+ x = self.MockRawIO()
+ with self.assertRaises(AttributeError):
+ buf.raw = x
+
class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
read_mode = "rb"
@@ -2245,6 +2252,12 @@
self.assertRaises(self.UnsupportedOperation, txt.tell)
self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
+ def test_readonly_attributes(self):
+ txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
+ buf = self.BytesIO(self.testdata)
+ with self.assertRaises(AttributeError):
+ txt.buffer = buf
+
class CTextIOWrapperTest(TextIOWrapperTest):
def test_initialization(self):