diff options
author | Brett Cannon <brett@python.org> | 2013-02-03 16:39:02 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-02-03 16:39:02 (GMT) |
commit | 2fb00bb5d32eb194daa18b92e12e6d842cada738 (patch) | |
tree | 00a1b5015b6d2a8af5c5ec9079627233834e3aa6 /Lib/test | |
parent | 9de80ac127a9cd9fab39844fcf0a58d1f9720363 (diff) | |
parent | d03ce4ae3d71ba84e1e30cf0cf221ec89ad5aa67 (diff) | |
download | cpython-2fb00bb5d32eb194daa18b92e12e6d842cada738.zip cpython-2fb00bb5d32eb194daa18b92e12e6d842cada738.tar.gz cpython-2fb00bb5d32eb194daa18b92e12e6d842cada738.tar.bz2 |
merge
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_io.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 1cf0527..57b22c6 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2542,6 +2542,30 @@ class TextIOWrapperTest(unittest.TestCase): txt.write('5') self.assertEqual(b''.join(raw._write_stack), b'123\n45') + def test_read_nonbytes(self): + # Issue #17106 + # Crash when underlying read() returns non-bytes + t = self.TextIOWrapper(self.StringIO('a')) + self.assertRaises(TypeError, t.read, 1) + t = self.TextIOWrapper(self.StringIO('a')) + self.assertRaises(TypeError, t.readline) + t = self.TextIOWrapper(self.StringIO('a')) + self.assertRaises(TypeError, t.read) + + def test_illegal_decoder(self): + # Issue #17106 + # Crash when decoder returns non-string + t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', + encoding='quopri_codec') + self.assertRaises(TypeError, t.read, 1) + t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', + encoding='quopri_codec') + self.assertRaises(TypeError, t.readline) + t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', + encoding='quopri_codec') + self.assertRaises(TypeError, t.read) + + class CTextIOWrapperTest(TextIOWrapperTest): def test_initialization(self): |