classification
Title: zipfile: AttributeError on extract (LZMA)
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: zipfile: AttributeError on extract
View: 36991
Assigned To: Nosy List: alter-bug-tracer, berker.peksag, matrixise
Priority: normal Keywords:

Created on 2019-05-21 12:29 by alter-bug-tracer, last changed 2019-06-01 16:20 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
attr1.zip alter-bug-tracer, 2019-05-21 12:29
Messages (3)
msg343036 - (view) Author: alter-bug-tracer (alter-bug-tracer) * Date: 2019-05-21 12:29
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 1679, in _extract_member
    shutil.copyfileobj(source, target)
  File "/usr/local/lib/python3.8/shutil.py", line 198, in copyfileobj
    buf = fsrc_read(length)
  File "/usr/local/lib/python3.8/zipfile.py", line 903, in read
    data = self._read1(n)
  File "/usr/local/lib/python3.8/zipfile.py", line 986, in _read1
    data = self._decompressor.decompress(data)
  File "/usr/local/lib/python3.8/zipfile.py", line 635, in decompress
    self._decomp = lzma.LZMADecompressor(lzma.FORMAT_RAW, filters=[
AttributeError: 'NoneType' object has no attribute 'LZMADecompressor'
msg343156 - (view) Author: St├ęphane Wirtel (matrixise) * (Python committer) Date: 2019-05-22 08:29
Hi, 

Thank you for your report

but do you have the lzma lib on your system, because without that, Python is not compiled with the support of this format.

example, with a debian docker image:

without all the needed libraries you would get this exception:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _hashlib           
_lzma                 _sqlite3              _ssl               
_tkinter              _uuid                 readline           
zlib                                                           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd                
time                                                           


Failed to build these modules:
_ctypes                                                        

Please could you check again your compilation step and retry with an other file.

I'm closing this issue but you are free to re-open it if you have tested with the right dependencies.

Thank you
msg344184 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2019-06-01 16:20
This is a duplicate of issue 36991 and will be fixed by the same PR.
History
Date User Action Args
2019-06-01 16:20:23berker.peksagsetnosy: + berker.peksag
messages: + msg344184
resolution: not a bug -> duplicate

superseder: zipfile: AttributeError on extract
2019-05-22 08:29:29matrixisesetstatus: open -> closed

nosy: + matrixise
messages: + msg343156

resolution: not a bug
stage: resolved
2019-05-21 12:29:31alter-bug-tracercreate