summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-04-12 13:03:23 (GMT)
committerGitHub <noreply@github.com>2017-04-12 13:03:23 (GMT)
commit4c0d9ea995da595e90e08813b89510de59907802 (patch)
tree1c6138fb627ad1f5b982cc67dafd230d50f8cc27 /Lib/zipfile.py
parent3e0f1fc4e0ffcfcc706015fa3d67c262948ef171 (diff)
downloadcpython-4c0d9ea995da595e90e08813b89510de59907802.zip
cpython-4c0d9ea995da595e90e08813b89510de59907802.tar.gz
cpython-4c0d9ea995da595e90e08813b89510de59907802.tar.bz2
bpo-30017: Allowed calling the close() method of the zip entry writer object (#1041)
multiple times. Writing to closed zip entry writer object now always produce a ValueError.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 550e64f..988f39e 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -980,6 +980,8 @@ class _ZipWriteFile(io.BufferedIOBase):
return True
def write(self, data):
+ if self.closed:
+ raise ValueError('I/O operation on closed file.')
nbytes = len(data)
self._file_size += nbytes
self._crc = crc32(data, self._crc)
@@ -990,6 +992,8 @@ class _ZipWriteFile(io.BufferedIOBase):
return nbytes
def close(self):
+ if self.closed:
+ return
super().close()
# Flush any data from the compressor, and update header info
if self._compressor: