Skip to content

zipfile: AttributeError on extract (LZMA) #81173

Closed

Description

@alter-bug-tracer
BPO 36992
Nosy @berkerpeksag, @matrixise, @alter-bug-tracer
Superseder
  • bpo-36991: zipfile: AttributeError on extract
  • Files
  • attr1.zip
  • 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:

    assignee = None
    closed_at = <Date 2019-05-22.08:29:29.019>
    created_at = <Date 2019-05-21.12:29:31.688>
    labels = ['type-bug', '3.8']
    title = 'zipfile: AttributeError on extract (LZMA)'
    updated_at = <Date 2019-06-01.16:20:23.804>
    user = 'https://github.com/alter-bug-tracer'

    bugs.python.org fields:

    activity = <Date 2019-06-01.16:20:23.804>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-22.08:29:29.019>
    closer = 'matrixise'
    components = []
    creation = <Date 2019-05-21.12:29:31.688>
    creator = 'alter-bug-tracer'
    dependencies = []
    files = ['48347']
    hgrepos = []
    issue_num = 36992
    keywords = []
    message_count = 3.0
    messages = ['343036', '343156', '344184']
    nosy_count = 3.0
    nosy_names = ['berker.peksag', 'matrixise', 'alter-bug-tracer']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '36991'
    type = 'behavior'
    url = 'https://bugs.python.org/issue36992'
    versions = ['Python 3.8']

    Activity

    1. alter-bug-tracer commented on May 21, 2019

      alter-bug-tracermannequin
      MannequinAuthor

      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'
    2. added
      3.8 (EOL)
      type-bug
      on May 21, 2019
    3. matrixise commented on May 22, 2019

      @matrixise
      Member

      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

    4. berkerpeksag commented on Jun 1, 2019

      @berkerpeksag
      Member

      This is a duplicate of bpo-36991 and will be fixed by the same PR.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)type-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions