Skip to content

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

Merged
rhpvorderman merged 2 commits into
pycompression:developfrom
ptweezy:gzipreader-seekable
Nov 16, 2026
Merged

rhpvorderman merged 2 commits 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.
@rhpvorderman

Copy link
Copy Markdown
Collaborator

Thanks. Looks good. Unfortunately thread sanitizer fails, but that seems to be not related to this PR.

@rhpvorderman
rhpvorderman merged commit 9867f49 into pycompression:develop Nov 16, 2026
46 of 48 checks passed
@ptweezy
ptweezy deleted the gzipreader-seekable branch November 16, 2026 16:44
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.

2 participants