summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-04-16 09:04:45 (GMT)
committerGitHub <noreply@github.com>2017-04-16 09:04:45 (GMT)
commit8e5b52a8da07e781bda50ba0a7065b1058495a37 (patch)
tree05226e7e15eb9291fd43e54d8cf56366a3e2a335 /Lib/zipfile.py
parentd5fa5f3ce7d9003bbd3975d1bf634043305ae18f (diff)
downloadcpython-8e5b52a8da07e781bda50ba0a7065b1058495a37.zip
cpython-8e5b52a8da07e781bda50ba0a7065b1058495a37.tar.gz
cpython-8e5b52a8da07e781bda50ba0a7065b1058495a37.tar.bz2
bpo-30017: Allowed calling the close() method of the zip entry writer object (#1041) (#1092)
multiple times. Writing to closed zip entry writer object now always produce a ValueError. (cherry picked from commit 4c0d9ea995da595e90e08813b89510de59907802)
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 d7f5beb..06eedec 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -981,6 +981,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)
@@ -991,6 +993,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: