mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-37523: Raise ValueError for I/O operations on a closed zipfile.ZipExtFile. (GH-14658)
Raises ValueError when calling the following on a closed zipfile.ZipExtFile: read, readable, seek, seekable, tell.
This commit is contained in:
parent
1df65f7c6c
commit
8d62df60d8
3 changed files with 25 additions and 0 deletions
|
|
@ -571,6 +571,20 @@ class StoredTestsWithSourceFile(AbstractTestsWithSourceFile,
|
|||
with open(TESTFN, "rb") as f:
|
||||
self.assertEqual(zipfp.read(TESTFN), f.read())
|
||||
|
||||
def test_io_on_closed_zipextfile(self):
|
||||
fname = "somefile.txt"
|
||||
with zipfile.ZipFile(TESTFN2, mode="w") as zipfp:
|
||||
zipfp.writestr(fname, "bogus")
|
||||
|
||||
with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:
|
||||
with zipfp.open(fname) as fid:
|
||||
fid.close()
|
||||
self.assertRaises(ValueError, fid.read)
|
||||
self.assertRaises(ValueError, fid.seek, 0)
|
||||
self.assertRaises(ValueError, fid.tell)
|
||||
self.assertRaises(ValueError, fid.readable)
|
||||
self.assertRaises(ValueError, fid.seekable)
|
||||
|
||||
def test_write_to_readonly(self):
|
||||
"""Check that trying to call write() on a readonly ZipFile object
|
||||
raises a ValueError."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue