summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:01:05 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:01:05 (GMT)
commitd10d6ae2fad2c1963e119ed7bc031b723603b363 (patch)
treef20bea510727f668e68c89320a18a8a81c8ba36f /Lib/test/test_io.py
parent1aa5e1d63e6452234065e73e59b9f4db2c2efdeb (diff)
downloadcpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.zip
cpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.tar.gz
cpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.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 46b896f..f7c6e2d 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1191,6 +1191,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