This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: cannot decrypt multiple members from Windows 7zFM
Type: behavior Stage: resolved
Components: Library (Lib) Versions:
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: era, serhiy.storchaka
Priority: normal Keywords:

Created on 2015-06-11 13:53 by era, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit era, 2015-06-11 13:53 Simple encrypted 7z archive with two members, password hello
Messages (3)
msg245165 - (view) Author: (era) Date: 2015-06-11 13:53
The attached archive from the Windows version of the 7z file manager (7zFM version 9.20) cannot be decrypted into memory.  The first file succeeds, but the second one fails.

The following small program is able to unzip other encrypted zip archives (tried one created by Linux 7z version 9.04 on Debian from the package p7zip-full, and one from plain zip 3.0-3 which comes from the InfoZip distribution, as well as a number of archives of unknown provenance) but fails on the attached one.

from zipfile import ZipFile
from sys import argv

container = ZipFile(argv[1])
for member in container.namelist():
    print("member %s" % member)
        extracted =
        print("extracted %s" % repr(extracted)[0:64])
    except RuntimeError, err:
        extracted =, 'hello')
        print("extracted with password 'hello': %s" % repr(extracted)[0:64])

Here is the output and backtrace:

member hello/
extracted ''
member hello/goodbye.txt
Traceback (most recent call last):
  File "./", line 13, in <module>
    extracted =, 'hello')
  File "/usr/lib/python2.6/", line 834, in read
    return, "r", pwd).read()
  File "/usr/lib/python2.6/", line 901, in open
    raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', 'hello/goodbye.txt')

The 7z command is able to extract it just fine:

$ 7z -phello x /tmp/

7-Zip 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)

Processing archive: /tmp/

Extracting  hello
Extracting  hello/goodbye.txt
Extracting  hello/hello.txt

Everything is Ok

Folders: 1
Files: 2
Size:       15
Compressed: 560
msg245166 - (view) Author: (era) Date: 2015-06-11 14:00
The call to .setpassword() doesn't seem to make any difference.  I was hoping it would offer a workaround, but it didn't.
msg245167 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-06-11 14:29
The file looks not conforming ZIP file specification.

The 12th byte of an encryption header doesn't match the MSB of the CRC, therefore the error. And even ignoring it, compression type 99 is not supported by the zipfile module and even is not mentioned in the specification.

With what command this archive was created?
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68618
2019-10-27 10:22:07serhiy.storchakasetstatus: open -> closed
resolution: not a bug
stage: resolved
2015-06-11 14:29:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg245167
2015-06-11 14:00:09erasetmessages: + msg245166
2015-06-11 13:54:33erasettype: behavior
components: + Library (Lib)
title: cannot decrypt multiple members from Windows 7zfm -> cannot decrypt multiple members from Windows 7zFM
2015-06-11 13:53:41eracreate