mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
1aa5e1d63e
commit
d10d6ae2fa
3 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue