diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2012-05-01 06:38:01 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2012-05-01 06:38:01 (GMT) |
commit | b3260f08cf9066367f63dccbac60798d555e52b9 (patch) | |
tree | f881c9997a44593b2bbea29f9ccae7d3cb8b1da7 /Lib/zipfile.py | |
parent | f6b16a4b507723b1a22e6cc5af80150f189b3e9d (diff) | |
download | cpython-b3260f08cf9066367f63dccbac60798d555e52b9.zip cpython-b3260f08cf9066367f63dccbac60798d555e52b9.tar.gz cpython-b3260f08cf9066367f63dccbac60798d555e52b9.tar.bz2 |
Detect unsupported compression types.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 1cdfceb..ff7f30f 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -504,12 +504,29 @@ def _get_compressor(compress_type): def _get_decompressor(compress_type): - if compress_type == ZIP_DEFLATED: + if compress_type == ZIP_STORED: + return None + elif compress_type == ZIP_DEFLATED: return zlib.decompressobj(-15) elif compress_type == ZIP_BZIP2: return bz2.BZ2Decompressor() else: - return None + unknown_compressors = { + 1: 'shrink', + 2: 'reduce', + 3: 'reduce', + 4: 'reduce', + 5: 'reduce', + 6: 'implode', + 9: 'enhanced deflate', + 10: 'implode', + 14: 'lzma', + } + descr = unknown_compressors.get(compress_type) + if descr: + raise NotImplementedError("compression type %d (%s)" % (compress_type, descr)) + else: + raise NotImplementedError("compression type %d" % (compress_type,)) class ZipExtFile(io.BufferedIOBase): |