[Python-checkins] cpython: #15546: Also fix GzipFile.peek().
nadeem.vawda
python-checkins at python.org
Sun Aug 5 14:48:09 CEST 2012
http://hg.python.org/cpython/rev/8c07ff7f882f
changeset: 78431:8c07ff7f882f
user: Nadeem Vawda <nadeem.vawda at gmail.com>
date: Sun Aug 05 14:45:41 2012 +0200
summary:
#15546: Also fix GzipFile.peek().
files:
Lib/gzip.py | 6 ++++--
Misc/NEWS | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Lib/gzip.py b/Lib/gzip.py
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -413,8 +413,10 @@
if self.fileobj is None:
return b''
try:
- # 1024 is the same buffering heuristic used in read()
- self._read(max(n, 1024))
+ # Ensure that we don't return b"" if we haven't reached EOF.
+ while self.extrasize == 0:
+ # 1024 is the same buffering heuristic used in read()
+ self._read(max(n, 1024))
except EOFError:
pass
offset = self.offset - self.extrastart
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,8 +81,8 @@
constructor, objects in the ipaddress module no longer implement __index__
(they still implement __int__ as appropriate)
-- Issue #15546: Fix handling of pathological input data in the read1() method of
- the BZ2File, GzipFile and LZMAFile classes.
+- Issue #15546: Fix handling of pathological input data in the peek() and
+ read1() methods of the BZ2File, GzipFile and LZMAFile classes.
- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
ended with '\'. Patch by Roger Serwy.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list