mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #10750: The raw
attribute of buffered IO objects is now read-only.
This commit is contained in:
parent
cfee0e83eb
commit
7f8f41808b
4 changed files with 32 additions and 9 deletions
|
@ -730,6 +730,13 @@ class CommonBufferedTests:
|
|||
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 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue