Author martin.panter
Recipients Walt Askew, cheryl.sabella, martin.panter, pitrou, xtreak
Date 2018-10-06.06:03:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If a change is made, it would be nice to bring the “gzip”, “bzip” and LZMA modules closer together. The current “bzip” and LZMA modules rely on the underlying “seekable” method without a fallback implementation, but also have a check for read mode.

I think the seeking functionality in these modules is a misfeature. But since it is already here, it is probably best to leave it alone, and just document it.

My comment about making “seekable” stricter is at <>. Even if the underlying stream is not seekable, GzipFile can still fast-forward. Here is a demonstration:

>>> z = BytesIO(bytes.fromhex(
...     "1F8B08000000000002FFF348CD29D051F05448CC55282E294DCE56C8CC53485448AFCA"
...     "2C5048CBCC490500F44BF0A01F000000"
... ))
>>> def seek(*args): raise UnsupportedOperation()
>>> = seek  # Make the underlying stream not seekable
>>> f = GzipFile(fileobj=z)
b'Help, I am'
>>>  # Fast forward
b'a gzip file'
>>>  # Rewind
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/proj/python/cpython/Lib/", line 368, in seek
    return, whence)
  File "/home/proj/python/cpython/Lib/", line 137, in seek
  File "/home/proj/python/cpython/Lib/", line 515, in _rewind
  File "/home/proj/python/cpython/Lib/", line 115, in _rewind
  File "/home/proj/python/cpython/Lib/", line 105, in seek
  File "<stdin>", line 1, in seek
Date User Action Args
2018-10-06 06:03:22martin.pantersetrecipients: + martin.panter, pitrou, cheryl.sabella, Walt Askew, xtreak
2018-10-06 06:03:22martin.pantersetmessageid: <>
2018-10-06 06:03:22martin.panterlinkissue33173 messages
2018-10-06 06:03:22martin.pantercreate