summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:13:56 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:13:56 (GMT)
commitea6d5592f2964a17b14c1714bb06fe01918323b5 (patch)
tree2191daef69ec1b37cceddf95bc8160388fa2051a /Lib/test/test_io.py
parentb9db9e152f3325b075e59ef4fdecfd0b9ec4746c (diff)
downloadcpython-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.py8
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