mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
3e0f1fc4e0
commit
4c0d9ea995
3 changed files with 49 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue