mirror of
https://github.com/python/cpython.git
synced 2025-08-15 14:20:55 +00:00
Merged revisions 84737 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84737 | antoine.pitrou | 2010-09-12 16:51:20 +0200 (dim., 12 sept. 2010) | 4 lines Issue #9837: The read() method of ZipExtFile objects (as returned by ZipFile.open()) could return more bytes than requested. ........
This commit is contained in:
parent
2039753a9a
commit
e4195e8825
3 changed files with 32 additions and 6 deletions
|
@ -565,17 +565,20 @@ class ZipExtFile(io.BufferedIOBase):
|
|||
"""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 = ''
|
||||
while n < 0 or n is None or n > len(buf):
|
||||
data = self.read1(n)
|
||||
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))
|
||||
else:
|
||||
return buf
|
||||
if len(data) == 0:
|
||||
return buf
|
||||
|
||||
buf += data
|
||||
|
||||
return buf
|
||||
|
||||
def _update_crc(self, newdata, eof):
|
||||
# Update the CRC using the given data.
|
||||
if self._expected_crc is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue