diff options
author | Brett Cannon <brett@python.org> | 2013-02-03 16:38:38 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-02-03 16:38:38 (GMT) |
commit | 416e54cfe15d37c93ab39d742b453f89834c95e5 (patch) | |
tree | dbab4b1f09be74e5c58bd7d5600f31324e4a04f2 /Lib/test | |
parent | df80914a1e7acbcf5d4c311cb2d3ab4023e7128e (diff) | |
parent | cce1b8eda8b697e68cb7233332f110a6a7a684a2 (diff) | |
download | cpython-416e54cfe15d37c93ab39d742b453f89834c95e5.zip cpython-416e54cfe15d37c93ab39d742b453f89834c95e5.tar.gz cpython-416e54cfe15d37c93ab39d742b453f89834c95e5.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 8727dde..5fe4a8d 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2550,6 +2550,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): |