diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-19 17:25:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-19 17:25:29 (GMT) |
commit | a5af6e1af77ee0f9294c5776478a9c24d9fbab94 (patch) | |
tree | f4c9791260db737fea9da4f415d9facad9c96ae1 /Lib/test/test_io.py | |
parent | 77ed11552da3e01dd235b7d68988076866b1f604 (diff) | |
download | cpython-a5af6e1af77ee0f9294c5776478a9c24d9fbab94.zip cpython-a5af6e1af77ee0f9294c5776478a9c24d9fbab94.tar.gz cpython-a5af6e1af77ee0f9294c5776478a9c24d9fbab94.tar.bz2 |
bpo-25455: Fixed crashes in repr of recursive buffered file-like objects. (#514)
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index fc68b09..929865d 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1014,6 +1014,16 @@ class CommonBufferedTests: raw.name = b"dummy" self.assertEqual(repr(b), "<%s name=b'dummy'>" % clsname) + def test_recursive_repr(self): + # Issue #25455 + raw = self.MockRawIO() + b = self.tp(raw) + with support.swap_attr(raw, 'name', b): + try: + repr(b) # Should not crash + except RuntimeError: + pass + def test_flush_error_on_close(self): # Test that buffered file is closed despite failed flush # and that flush() is called before file closed. @@ -2435,6 +2445,16 @@ class TextIOWrapperTest(unittest.TestCase): t.buffer.detach() repr(t) # Should not raise an exception + def test_recursive_repr(self): + # Issue #25455 + raw = self.BytesIO() + t = self.TextIOWrapper(raw) + with support.swap_attr(raw, 'name', t): + try: + repr(t) # Should not crash + except RuntimeError: + pass + def test_line_buffering(self): r = self.BytesIO() b = self.BufferedWriter(r, 1000) |