diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-08-05 12:45:41 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-08-05 12:45:41 (GMT) |
commit | 043540088ae75f79179de2fe4ec147674bcc2a5f (patch) | |
tree | 5bad89b4fe613e1552247a128b59bf7a8bb44ae8 /Lib | |
parent | e3ded955f3b145e38be47be61c53ba1ff130f47b (diff) | |
download | cpython-043540088ae75f79179de2fe4ec147674bcc2a5f.zip cpython-043540088ae75f79179de2fe4ec147674bcc2a5f.tar.gz cpython-043540088ae75f79179de2fe4ec147674bcc2a5f.tar.bz2 |
#15546: Also fix GzipFile.peek().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/gzip.py | 6 |
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 |