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: AttributeError on extract #81172
Comments
The following code throws an AttributeError when attempting to extract a malformed archive (attached): import zipfile
import sys
zf = zipfile.ZipFile(sys.argv[1])
for info in zf.infolist():
zf.extract(info.filename) Result:
Traceback (most recent call last):
File "code.py", line 6, in <module>
zf.extract(info.filename)
File "/usr/local/lib/python3.8/zipfile.py", line 1607, in extract
return self._extract_member(member, path, pwd)
File "/usr/local/lib/python3.8/zipfile.py", line 1677, in _extract_member
with self.open(member, pwd=pwd) as source, \
File "/usr/local/lib/python3.8/zipfile.py", line 1548, in open
return ZipExtFile(zef_file, mode, zinfo, zd, True)
File "/usr/local/lib/python3.8/zipfile.py", line 801, in __init__
self._decompressor = _get_decompressor(self._compress_type)
File "/usr/local/lib/python3.8/zipfile.py", line 708, in _get_decompressor
return bz2.BZ2Decompressor()
AttributeError: 'NoneType' object has no attribute 'BZ2Decompressor' |
Hi, Thank you for your report
unzip attr0.zip Please could you check again your compilation step and retry with an other file. I'm closing this issue. Thank you |
I also recommend that you read this document about the compilation and installation of Python and its dependencies. https://devguide.python.org/setup/#compile-and-build Thank you |
The OP's report is valid and they already stated that the file is malformed. More importantly, this can be reproduced with a valid ZIP file as well. The correct behavior is to get RuntimeError in this case. _check_compression() needs to be called before _get_decompressor(). There is no issue when getting the compressor object because _check_compression() is called inside _writecheck(). |
This seems resolved, can we close? |
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: