This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: gzip.GzipFile.flush() does not flush all internal buffers
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alanmcintyre, dschnepper, loewis
Priority: normal Keywords:

Created on 2005-01-26 21:42 by dschnepper, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pybug2.py dschnepper, 2005-01-26 21:42 demonstrates problem with gzip.GzipFile.flush
diff.out dschnepper, 2005-01-26 21:55 Patch for lib/gzip.py
Messages (4)
msg24062 - (view) Author: David Schnepper (dschnepper) Date: 2005-01-26 21:42
flush() is expected to output all pending data stored
in internal buffers.

gzip.GzipFile.flush() does perform a flush on its
fileobj, but does not flush the state of its compressobj
prior to the IO flush.

This results in being able to use gzip.GzipFile to zip 
output to a socket and having the other side unzip it
in sync with originators flush calls.
msg24063 - (view) Author: Alan McIntyre (alanmcintyre) * (Python committer) Date: 2005-02-27 04:33
Logged In: YES 
user_id=1115903

This patch appears to fix the bug as described, and running
the regression tests on Python 2.5a0 (CVS HEAD) plus this
patch turns up no problems.  Since the documentation says
that a GzipFile "simulates most of the methods of a file
object," I would expect GzipFile.flush() to act in the way
that David described in the first paragraph of the bug
report, and his patch seems to provide that as far as I can
tell.
msg24064 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 08:38
Logged In: YES 
user_id=21627

Thanks for the patch. I believe it does not fully fix the
bug reported: not all input data are flushed with
Z_SYNC_FLUSH, but only some (up to an output byte boundary
or some such). I also believe that a "complete" fix for the
bug is not possible, as flushing all input data would
require Z_FINISH, and then no more additional data could be
written into the stream.

As this is still an improvement over the current status, I
committed it as

gzip.py 1.43
NEWS 1.1251
msg24065 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 08:39
Logged In: YES 
user_id=21627

Ah, put the "committed" message into the wrong tracker item.
As I said, I don't think the bug is fully fixed, but I don't
think it can be fully fixed, either, so closing it as fixed.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41495
2005-01-26 21:42:06dschneppercreate