[New-bugs-announce] [issue15087] Add gzip function to read gzip'd strings

Raymond Hettinger report at bugs.python.org
Sun Jun 17 03:34:39 CEST 2012

New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

The API for the gzip module is convenient for reading gzipped file but is rather awkward for reading bytes downloaded from a socket:

  >>> import gzip, io
  >>> from urllib.request import urlopen, Request
  >>> u = urlopen(Request('http://www.nytimes.com', headers={'Accept-Encoding': 'gzip'}))
  >>> content = gzip.GzipFile(fileobj=io.BytesIO(u.read()), mode='rb').read()

It would be better if the last line could be written:

  >>> content = gzip.decompress_file(u)

components: Library (Lib)
messages: 163004
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add gzip function to read gzip'd strings
type: enhancement
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list