diff -r 54dc01ff643b lib-python/2.7/zipfile.py --- a/lib-python/2.7/zipfile.py Tue May 02 11:00:13 2017 -0700 +++ b/lib-python/2.7/zipfile.py Thu May 18 15:27:16 2017 +0300 @@ -622,19 +622,22 @@ """Read and return up to n bytes. If the argument is omitted, None, or negative, data is read and returned until EOF is reached.. """ - buf = '' + buf = [] + lenbuf = 0 if n is None: n = -1 while True: if n < 0: data = self.read1(n) - elif n > len(buf): - data = self.read1(n - len(buf)) + elif n > lenbuf: + data = self.read1(n - lenbuf) else: - return buf + break if len(data) == 0: - return buf - buf += data + break + lenbuf += len(data) + buf.append(data) + return ''.join(buf) def _update_crc(self, newdata, eof): # Update the CRC using the given data. @@ -874,9 +877,7 @@ def namelist(self): """Return a list of file names in the archive.""" - l = [] - for data in self.filelist: - l.append(data.filename) + l = [data.filename for data in self.filelist] return l def infolist(self): @@ -1039,7 +1040,6 @@ """ if members is None: members = self.namelist() - for zipinfo in members: self.extract(zipinfo, path, pwd) @@ -1082,11 +1082,9 @@ if not os.path.isdir(targetpath): os.mkdir(targetpath) return targetpath - with self.open(member, pwd=pwd) as source, \ - file(targetpath, "wb") as target: - shutil.copyfileobj(source, target) - + open(targetpath, "wb") as target: + shutil.copyfileobj(source, target, length = 128 * 1024) return targetpath def _writecheck(self, zinfo):