summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-08-05 12:45:41 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-08-05 12:45:41 (GMT)
commit043540088ae75f79179de2fe4ec147674bcc2a5f (patch)
tree5bad89b4fe613e1552247a128b59bf7a8bb44ae8 /Lib
parente3ded955f3b145e38be47be61c53ba1ff130f47b (diff)
downloadcpython-043540088ae75f79179de2fe4ec147674bcc2a5f.zip
cpython-043540088ae75f79179de2fe4ec147674bcc2a5f.tar.gz
cpython-043540088ae75f79179de2fe4ec147674bcc2a5f.tar.bz2
#15546: Also fix GzipFile.peek().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gzip.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 5bcfe61..b6656a9 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -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