summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-09-27 19:37:27 +0000
committerAndrew M. Kuchling <amk@amk.ca>2006-09-27 19:37:27 +0000
commitf21bdb4c25052b259c16736558d58c402f104be9 (patch)
treeff6558d6cc9455e2f0637cf4d91b979f2f74baad
parentc39c7c1d0402dd9df618ff876df3aa6793129906 (diff)
downloadcpython-git-f21bdb4c25052b259c16736558d58c402f104be9.tar.gz
[Backport rev. 38534 by loewis]
[Possibly controversial because it adds a parameter to a method. This parameter isn't documented, however, so arguably it's a private detail, and the fix is necessary to make GzipFile.flush() behave more similarly to regular file object.] Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. Partially fixes #1110242.
-rw-r--r--Lib/gzip.py5
-rw-r--r--Misc/NEWS1
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index cec8c0eead..ecfd98cb45 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -332,7 +332,10 @@ class GzipFile:
return
self.close()
- def flush(self):
+ def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH):
+ if self.mode == WRITE:
+ # Ensure the compressor's buffer is flushed
+ self.fileobj.write(self.compress.flush(zlib_mode))
self.fileobj.flush()
def fileno(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index b966fae786..28bc76a973 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -176,6 +176,7 @@ Library
- Bug #1472827: correctly escape newlines and tabs in attribute values in
the saxutils.XMLGenerator class.
+- Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush.
Tools/Demos
-----------