[Python-checkins] cpython (2.7): Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of

serhiy.storchaka python-checkins at python.org
Sat Dec 21 22:52:32 CET 2013


http://hg.python.org/cpython/rev/8b097d07488d
changeset: 88117:8b097d07488d
branch: 2.7
parent: 88084:81f8375e60ce
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Dec 21 23:51:15 2013 +0200
summary:
 Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of
the uncompress buffer and read() goes through more than one readbuffer.
This is partial backport of changeset 028e8e0b03e8.
files:
 Lib/zipfile.py | 6 +++++-
 Misc/NEWS | 3 +++
 2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -606,7 +606,11 @@
 """Returns buffered bytes without advancing the position."""
 if n > len(self._readbuffer) - self._offset:
 chunk = self.read(n)
- self._offset -= len(chunk)
+ if len(chunk) > self._offset:
+ self._readbuffer = chunk + self._readbuffer[self._offset:]
+ self._offset = 0
+ else:
+ self._offset -= len(chunk)
 
 # Return up to 512 bytes to reduce allocation overhead for tight loops.
 return self._readbuffer[self._offset: self._offset + 512]
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@
 Library
 -------
 
+- Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of
+ the uncompress buffer and read() goes through more than one readbuffer.
+
 - Issue #20034: Updated alias mapping to most recent locale.alias file
 from X.org distribution using makelocalealias.py.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /