mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
fix TextIOWrapper.read() when the buffer is not readable #5628
This commit is contained in:
parent
d2ee64d9dd
commit
a1b49013f4
4 changed files with 15 additions and 0 deletions
|
@ -1754,6 +1754,13 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
self.assertEquals(f.read(), data * 2)
|
||||
self.assertEquals(buf.getvalue(), (data * 2).encode(encoding))
|
||||
|
||||
def test_unreadable(self):
|
||||
class UnReadable(self.BytesIO):
|
||||
def readable(self):
|
||||
return False
|
||||
txt = self.TextIOWrapper(UnReadable())
|
||||
self.assertRaises(IOError, txt.read)
|
||||
|
||||
def test_read_one_by_one(self):
|
||||
txt = self.TextIOWrapper(self.BytesIO(b"AA\r\nBB"))
|
||||
reads = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue