mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #23796: peak and read1 methods of BufferedReader now raise ValueError
if they called on a closed object. Patch by John Hergenroeder.
This commit is contained in:
parent
b9db9e152f
commit
ea6d5592f2
3 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue