[issue9664] Make gzip module not require that underlying file object support seek

Terry J. Reedy report at bugs.python.org
Tue Sep 7 17:24:12 CEST 2010


Terry J. Reedy <tjreedy at udel.edu> added the comment:

It is possible that only a fixed-size buffer is needed. If so, use of an alternate read mechanism could be conditioned on the underlying file(like) object not having seek.

It is also possible to direct a stream to a temporary file, but I think having the user do so explicitly is better so there are no surprises and so that the user has file reference for any further work.

Or their could be a context manager class for creating temp files from streams (or urls specifically) and deleting when done. One could then write

with TempStreamFile(urlopen('xxx') as f:
  for line in Gzipfile(fileobj=f):

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9664>
_______________________________________


More information about the Python-bugs-list mailing list