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.

classification
Title: zipfile should raise an exception for unsupported compression methods
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: alanmcintyre, amaury.forgeotdarc, eric.araujo, ezio.melotti, fidoman, loewis, python-dev, serhiy.storchaka, spmcinerney, v+python
Priority: normal Keywords: needs review, patch

Created on 2012-03-15 04:35 by fidoman, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.zip fidoman, 2012-03-15 04:35 unextractable archive
zipfile_unsupported_compression-3.2.patch serhiy.storchaka, 2012-05-16 20:15 Patch for 3.2 review
zipfile_unsupported_compression-2.7.patch serhiy.storchaka, 2012-05-16 20:15 Patch for 2.7 review
Messages (13)
msg155854 - (view) Author: Sergey Dorofeev (fidoman) Date: 2012-03-15 04:35
unzip does extract files but zipfile no
works fine with python2.7 but fails with python 3.2.2
tested on solaris 11 express and windows xp

>>> import zipfile
>>> zipfile.ZipFile("test.zip")
<zipfile.ZipFile object at 0x903e50>
>>> z=_
>>> z.namelist
<bound method ZipFile.namelist of <zipfile.ZipFile object at 0x903e50>>
>>> z.namelist()
['19A7B5A4.PKT']
>>> z.read('19A7B5A4.PKT')
b''
msg155872 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-03-15 08:57
This ZIP file uses a compression method unsupported by Python:
>>> z.getinfo('19A7B5A4.PKT').compress_type
6
which corresponds to "Imploded". Only "Stored" and "Deflated" are supported.

Note that previous versions don't work either: they just happen to return the compressed data.
msg156065 - (view) Author: Glenn Linderman (v+python) * Date: 2012-03-16 18:13
While Amaury's comment is no doubt true, shouldn't z.read raise an exception if it encounters an unsupported compression type?
msg156101 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-16 23:20
The requested change is arguably a new feature, but it seems to me that the current behavior is not acceptable and should be changed.
msg160628 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-05-14 15:31
Modified patch adopted in 3.3 (changeset 596b0eaeece8), therefore the current patch only applies to 3.2 and 2.7. If this is a new feature, the issue can be closed.
msg160660 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-05-14 20:17
Returning the compressed data from read() is clearly a bug (IMO), so detecting that and reporting an exception would be a bug fix.

I still like NotImplementedError more than RuntimeError, though.
msg160926 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-05-16 20:15
> I still like NotImplementedError more than RuntimeError, though.

Well. here are patches for Python 3.2 and 2.7 (backported changeset
596b0eaeece8 + part of changeset fccdcd83708a).
msg172545 - (view) Author: Stephen McInerney (spmcinerney) Date: 2012-10-10 00:38
The patch is great, can you approve it urgently please?

It is seriously buggy to silently return a bad filestream, and not just throw the exception. I just wasted over a day's productivity due to this. I'm not alone.

I would argue for raising priority to High. This is a bad bug with a simple but urgent fix.
msg172591 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-10-10 16:18
Raising priority won’t give more free time to the module maintainer, or change the planned date for the next release.  Thanks for reviewing the patch however, it is helpful.  Did you apply it and run the test suite?
msg172601 - (view) Author: Stephen McInerney (spmcinerney) Date: 2012-10-10 20:27
I visually reviewed the patch, it's fine by me. (Am not set up to compile it.)

When is 2.7.3.x release planned?
msg174477 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-01 21:21
Éric, this changes already in 3.3 (changeset 596b0eaeece8 + part of changeset fccdcd83708a).  This two patches only backport the fix to 2.7 and 3.2.
msg175865 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-18 11:23
New changeset 8feaa8d04c56 by Ezio Melotti in branch '2.7':
#14313: zipfile now raises NotImplementedError when the compression type is unknown.
http://hg.python.org/cpython/rev/8feaa8d04c56

New changeset b193a5dc7a58 by Ezio Melotti in branch '3.2':
#14313: zipfile now raises NotImplementedError when the compression type is unknown.
http://hg.python.org/cpython/rev/b193a5dc7a58

New changeset c2ba10b9d654 by Ezio Melotti in branch '3.3':
#14313: null merge.
http://hg.python.org/cpython/rev/c2ba10b9d654

New changeset 4b866e39d1fb by Ezio Melotti in branch 'default':
#14313: null merge.
http://hg.python.org/cpython/rev/4b866e39d1fb
msg175866 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-18 11:24
Fixed, thanks for the patches!
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58521
2012-12-03 15:57:12serhiy.storchakalinkissue5701 superseder
2012-11-18 11:24:34ezio.melottisetstatus: open -> closed

assignee: ezio.melotti

nosy: + ezio.melotti
messages: + msg175866
resolution: fixed
stage: patch review -> resolved
2012-11-18 11:23:09python-devsetnosy: + python-dev
messages: + msg175865
2012-11-01 21:21:23serhiy.storchakasetmessages: + msg174477
versions: - Python 3.3, Python 3.4
2012-11-01 21:17:23serhiy.storchakasetfiles: - zipfile_unsupported_compression.patch
2012-10-10 20:27:10spmcinerneysetmessages: + msg172601
2012-10-10 16:18:58eric.araujosetmessages: + msg172591
versions: + Python 3.3, Python 3.4
2012-10-10 00:38:10spmcinerneysetnosy: + spmcinerney
messages: + msg172545
2012-05-16 20:15:55serhiy.storchakasetfiles: + zipfile_unsupported_compression-3.2.patch, zipfile_unsupported_compression-2.7.patch

messages: + msg160926
2012-05-14 20:17:27loewissetmessages: + msg160660
2012-05-14 15:31:48serhiy.storchakasetnosy: + loewis, serhiy.storchaka

messages: + msg160628
versions: - Python 3.3
2012-05-14 13:45:03eric.araujosetkeywords: + needs review
stage: patch review
2012-04-29 13:17:56serhiy.storchakasetfiles: + zipfile_unsupported_compression.patch
keywords: + patch
2012-03-16 23:20:22eric.araujosettitle: zipfile does not unpack files from archive (files extracted have zero length) -> zipfile should raise an exception for unsupported compression methods
messages: + msg156101
versions: + Python 2.7, Python 3.3
2012-03-16 23:18:24eric.araujosetnosy: + alanmcintyre, eric.araujo

stage: needs patch -> (no value)
2012-03-16 18:13:51v+pythonsetnosy: + v+python
messages: + msg156065
2012-03-15 08:57:54amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg155872
stage: needs patch
2012-03-15 04:35:35fidomancreate