From: Andrew M. Kuchling Date: Wed, 27 Sep 2006 19:37:27 +0000 (+0000) Subject: [Backport rev. 38534 by loewis] X-Git-Tag: v2.4.4c1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f21bdb4c25052b259c16736558d58c402f104be9;p=thirdparty%2FPython%2Fcpython.git [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. --- diff --git a/Lib/gzip.py b/Lib/gzip.py index cec8c0eead1e..ecfd98cb459e 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 b966fae786c3..28bc76a973e5 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 -----------