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.

Title: GzipFile cannot be used for streaming
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 2.6, Python 2.5
Status: closed Resolution: duplicate
Dependencies: Superseder: gzip.GzipFile to accept stream as fileobj.
View: 914340
Assigned To: Nosy List: enrico, nadeem.vawda, ned.deily, stutzbach, ysj.ray
Priority: normal Keywords:

Created on 2011-03-19 16:18 by enrico, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg131427 - (view) Author: Enrico Zini (enrico) Date: 2011-03-19 16:18

this snippet does not work, because GzipFile wants a file-like object that can do tell() and seek():


import gzip
from urllib import urlopen

zfd = urlopen("")
fd = gzip.GzipFile(fileobj=zfd, mode="r")
for line in fd:

It must be possible to build a decompressing file-like object wrapper that can do without seeking, since it is obviously not a limitation of gzip decompression libraries. It would be extremely useful to have such a thing, as shown in the example snippet above.

Some more details (including a very annoying misrepresentation of the issue found in Dive Into Python) can be found at (I apologise about the ranting tone of the post).
msg131482 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-20 09:49
Looks like a duplicate issue of #9664 and #914340. And has been fixed in patch of #914340.
msg131545 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-03-20 21:28
As Ray points out, this feature is now available in Python 3.2. It was not backported to Python 2.7 as only bug fixes are now being accepted for Python 2.x, not new features.
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55817
2011-03-20 21:28:29ned.deilysetstatus: open -> closed

superseder: gzip.GzipFile to accept stream as fileobj.

nosy: + ned.deily
messages: + msg131545
resolution: duplicate
stage: resolved
2011-03-20 09:49:46ysj.raysetnosy: + ysj.ray
messages: + msg131482
2011-03-20 07:12:21nadeem.vawdasetnosy: + nadeem.vawda
2011-03-19 19:32:14stutzbachsetnosy: + stutzbach
2011-03-19 16:18:48enricocreate