-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zipfile breaks if signalled during write() #80615
Comments
Consider a simple write to a zip file: import zipfile with zipfile.ZipFile('/workdir/archive.zip', 'w', compression=zipfile.ZIP_DEFLATED) as zip_archive: If a signal handler is fired and raises an exception during certain points of write() execution, such an error occurs (py 3.7.2): Traceback (most recent call last):
File "zipissue.py", line 4, in <module>
zip_archive.write('/workdir/data.csv', arcname='data.csv')
File "/usr/local/lib/python3.7/zipfile.py", line 1744, in write
shutil.copyfileobj(src, dest, 1024*8)
File "/usr/local/lib/python3.7/zipfile.py", line 1107, in close
buf = self._compressor.flush()
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "zipissue.py", line 5, in <module>
print('exiting from context manager...')
File "/usr/local/lib/python3.7/zipfile.py", line 1265, in __exit__
self.close()
File "/usr/local/lib/python3.7/zipfile.py", line 1798, in close
raise ValueError("Can't close the ZIP file while there is "
ValueError: Can't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip.
Exception ignored in: <function ZipFile.__del__ at 0x7fbeea4fcd08>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/zipfile.py", line 1789, in __del__
File "/usr/local/lib/python3.7/zipfile.py", line 1798, in close
ValueError: Can't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip. Before any write the I believe that by simply moving |
Thank you for your report Andriy. 3.5 and 3.6 take only security bug fixes. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: