diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-19 19:34:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 19:34:58 (GMT) |
commit | 64aa4df8502ca5d0a8ffb767ff97f625625c758c (patch) | |
tree | 7f059f4e132f2b877eb93ae810189d71cff878cb /Lib/test | |
parent | 32c43fbfeeb1502d67e8fb24bb42fcd9b1cc750a (diff) | |
download | cpython-64aa4df8502ca5d0a8ffb767ff97f625625c758c.zip cpython-64aa4df8502ca5d0a8ffb767ff97f625625c758c.tar.gz cpython-64aa4df8502ca5d0a8ffb767ff97f625625c758c.tar.bz2 |
[2.7] bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (GH-1096) (GH-1180) (#1183)
raised an error.
(cherry picked from commit bf623ae8843dc30b28c574bec8d29fc14be59d86)
(cherry picked from commit 680fea4)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_io.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index fb91a2d..caca033 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -396,6 +396,22 @@ class IOTest(unittest.TestCase): with self.open(support.TESTFN, "r") as f: self.assertRaises(TypeError, f.readline, 5.3) + def test_readline_nonsizeable(self): + # Issue #30061 + # Crash when readline() returns an object without __len__ + class R(self.IOBase): + def readline(self): + return None + self.assertRaises((TypeError, StopIteration), next, R()) + + def test_next_nonsizeable(self): + # Issue #30061 + # Crash when next() returns an object without __len__ + class R(self.IOBase): + def next(self): + return None + self.assertRaises(TypeError, R().readlines, 1) + def test_raw_bytes_io(self): f = self.BytesIO() self.write_ops(f) |