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 = ""
Library
-------
+- Issue #5628: Fix io.TextIOWrapper.read() with a unreadable buffer.
+
- Issue #5619: Multiprocessing children disobey the debug flag and causes
popups on windows buildbots. Patch applied to work around this issue.
CHECK_CLOSED(self);
+ if (self->decoder == NULL) {
+ PyErr_SetString(PyExc_IOError, "not readable");
+ return NULL;
+ }
+
if (_TextIOWrapper_writeflush(self) < 0)
return NULL;