]> granicus.if.org Git - python/commitdiff
#15546: Also fix GzipFile.peek().
authorNadeem Vawda <nadeem.vawda@gmail.com>
Sun, 5 Aug 2012 12:45:41 +0000 (14:45 +0200)
committerNadeem Vawda <nadeem.vawda@gmail.com>
Sun, 5 Aug 2012 12:45:41 +0000 (14:45 +0200)
Lib/gzip.py
Misc/NEWS

index 5bcfe6123afe0f480e30b3a9fc7d159f05cdf702..b6656a933e8474634f47eacbbd6328348ec400d3 100644 (file)
@@ -413,8 +413,10 @@ class GzipFile(io.BufferedIOBase):
             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
index 92a4d798c44bbda3d84ae3365e3b56cde71d2413..53f62a0c71c87f6e8a27d0545c5eaa8fc2698ed6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,8 +81,8 @@ Library
   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.