diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-05-12 14:13:56 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-05-12 14:13:56 (GMT) |
commit | ea6d5592f2964a17b14c1714bb06fe01918323b5 (patch) | |
tree | 2191daef69ec1b37cceddf95bc8160388fa2051a /Lib/test/test_io.py | |
parent | b9db9e152f3325b075e59ef4fdecfd0b9ec4746c (diff) | |
download | cpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.zip cpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.tar.gz cpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.tar.bz2 |
Issue #23796: peak and read1 methods of BufferedReader now raise ValueError
if they called on a closed object.
Patch by John Hergenroeder.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 2fb1b1e..416c547 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1115,6 +1115,14 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): self.assertEqual(rawio._extraneous_reads, 0, "failed for {}: {} != 0".format(n, rawio._extraneous_reads)) + def test_read_on_closed(self): + # Issue #23796 + b = io.BufferedReader(io.BytesIO(b"12")) + b.read(1) + b.close() + self.assertRaises(ValueError, b.peek) + self.assertRaises(ValueError, b.read1, 1) + class CBufferedReaderTest(BufferedReaderTest, SizeofTest): tp = io.BufferedReader |