summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-01-28 01:44:41 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-01-28 01:44:41 (GMT)
commit92b4743719c9e61ea693e135513f4ef98b9254b4 (patch)
tree0d1361eac05808512c99832d43947c730d639393 /Lib/zipfile.py
parent2472f986e2cbf7f8486d41b6d2794122ecc2bf04 (diff)
downloadcpython-92b4743719c9e61ea693e135513f4ef98b9254b4.zip
cpython-92b4743719c9e61ea693e135513f4ef98b9254b4.tar.gz
cpython-92b4743719c9e61ea693e135513f4ef98b9254b4.tar.bz2
Merged revisions 77809 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77809 | ezio.melotti | 2010-01-28 03:41:30 +0200 (Thu, 28 Jan 2010) | 1 line avoid to use zlib when the compress type is not ZIP_DEFLATED ........
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 7ee5e2f..d5caf26 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -463,7 +463,12 @@ class ZipExtFile(io.BufferedIOBase):
self._fileobj = fileobj
self._decrypter = decrypter
- self._decompressor = zlib.decompressobj(-15)
+ self._compress_type = zipinfo.compress_type
+ self._compress_size = zipinfo.compress_size
+ self._compress_left = zipinfo.compress_size
+
+ if self._compress_type == ZIP_DEFLATED:
+ self._decompressor = zlib.decompressobj(-15)
self._unconsumed = b''
self._readbuffer = b''
@@ -472,10 +477,6 @@ class ZipExtFile(io.BufferedIOBase):
self._universal = 'U' in mode
self.newlines = None
- self._compress_type = zipinfo.compress_type
- self._compress_size = zipinfo.compress_size
- self._compress_left = zipinfo.compress_size
-
# Adjust read size for encrypted files since the first 12 bytes
# are for the encryption/password information.
if self._decrypter is not None:
@@ -591,7 +592,8 @@ class ZipExtFile(io.BufferedIOBase):
self._unconsumed += data
# Handle unconsumed data.
- if len(self._unconsumed) > 0 and n > len_readbuffer:
+ if (len(self._unconsumed) > 0 and n > len_readbuffer and
+ self._compress_type == ZIP_DEFLATED):
data = self._decompressor.decompress(
self._unconsumed,
max(n - len_readbuffer, self.MIN_READ_SIZE)