[Python-checkins] r77809 - python/trunk/Lib/zipfile.py
ezio.melotti
python-checkins at python.org
Thu Jan 28 02:41:30 CET 2010
Author: ezio.melotti
Date: Thu Jan 28 02:41:30 2010
New Revision: 77809
Log:
avoid to use zlib when the compress type is not ZIP_DEFLATED
Modified:
python/trunk/Lib/zipfile.py
Modified: python/trunk/Lib/zipfile.py
==============================================================================
--- python/trunk/Lib/zipfile.py (original)
+++ python/trunk/Lib/zipfile.py Thu Jan 28 02:41:30 2010
@@ -471,7 +471,12 @@
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 = ''
self._readbuffer = ''
@@ -480,10 +485,6 @@
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:
@@ -599,7 +600,8 @@
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)
More information about the Python-checkins
mailing list