diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-27 19:14:31 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-27 19:14:31 (GMT) |
commit | ab25c7c011fc5875f92ff351262ba7fa50ef1c8f (patch) | |
tree | d450edf62502035c454d8a3873410fe31b043fe7 /Lib/zipfile.py | |
parent | cb2c4fe649753bb8622a8d364ca25769557a1009 (diff) | |
parent | d2c07a58affecc3fb049652ee7a435c382e3a4d0 (diff) | |
download | cpython-ab25c7c011fc5875f92ff351262ba7fa50ef1c8f.zip cpython-ab25c7c011fc5875f92ff351262ba7fa50ef1c8f.tar.gz cpython-ab25c7c011fc5875f92ff351262ba7fa50ef1c8f.tar.bz2 |
Issue #19053: ZipExtFile.read1() with non-zero argument no more returns empty
bytes until end of data.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 7d6591f..ff58347 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -785,8 +785,11 @@ class ZipExtFile(io.BufferedIOBase): buf = self._readbuffer[self._offset:] self._readbuffer = b'' self._offset = 0 - data = self._read1(self.MAX_N) - buf += data + while not self._eof: + data = self._read1(self.MAX_N) + if data: + buf += data + break return buf end = n + self._offset @@ -800,12 +803,16 @@ class ZipExtFile(io.BufferedIOBase): self._readbuffer = b'' self._offset = 0 if n > 0: - data = self._read1(n) - if n < len(data): - self._readbuffer = data - self._offset = n - data = data[:n] - buf += data + while not self._eof: + data = self._read1(n) + if n < len(data): + self._readbuffer = data + self._offset = n + buf += data[:n] + break + if data: + buf += data + break return buf def _read1(self, n): |