]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport rev. 38534 by loewis]
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 27 Sep 2006 19:37:27 +0000 (19:37 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 27 Sep 2006 19:37:27 +0000 (19:37 +0000)
[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.

Lib/gzip.py
Misc/NEWS

index cec8c0eead1e5becc4be747505b98e7c3d88b351..ecfd98cb459e3bd7ec9d9d62c3cf2318c35dd1cc 100644 (file)
@@ -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):
index b966fae786c37d87e765f252aa4d122aaf218405..28bc76a973e5268fec4c52619019666950a43d7f 100644 (file)
--- 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
 -----------