Skip to content

Fix tell() and forward seek() calls on unseekable IGzipFile inputs - #324

Open
ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:gzipreader-seekable
Open

ptweezy wants to merge 1 commit into
pycompression:developfrom
ptweezy:gzipreader-seekable

Conversation

@ptweezy

@ptweezy ptweezy commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

On an IGzipFile that reads from an unseekable file object, such as a pipe or a socket, tell() and seek() raise io.UnsupportedOperation. gzip.GzipFile supports tell() and forward seeks on the same input. io.BufferedReader rejects both calls because _GzipReader.seekable() in src/isal/isal_zlibmodule.c returns fp.seekable(). This change makes _GzipReader.seekable() return True, as gzip._PaddedFile.seekable() does; a rewind still calls fp.seek(), as in gzip. The new test_tell_and_seek_forward_on_unseekable_file test fails on develop.

Checklist

  • Pull request details were added to CHANGELOG.rst
  • Documentation was updated (if needed)

_GzipReader.seekable() returned fp.seekable(), so io.BufferedReader
refused tell() and seek() on pipes and sockets. Return True, as
gzip._PaddedFile.seekable() does: seek() reads forward and calls
fp.seek() only to rewind.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant