Skip to content

gh-160071: Fix the gzip write-mode seek return value - #160075

Open
repzakske wants to merge 7 commits into
python:mainfrom
repzakske:fix/gzip-seek-write-position
Open

repzakske wants to merge 7 commits into
python:mainfrom
repzakske:fix/gzip-seek-write-position

Conversation

@repzakske

@repzakske repzakske commented Oct 21, 2026 •

Copy link
Copy Markdown

Writing b'header' and then calling GzipFile.seek(16) can return 6 while the actual position is 16. Code that uses the returned position to index records can therefore save incorrect offsets.

Return the computed absolute target position without forcing another flush. Regression coverage checks absolute and relative seeks, small and large padding, a buffered write followed by seek(0, SEEK_CUR), and decompressed contents.

Validation: Windows x64 debug build of current main; test_gzip, test_zlib, and test_tarfile passed (960 cases reported, 23 skipped). Ruff 0.15.17 passed. The regression fails with the unchanged upstream gzip implementation and passes with the fix. The complete CPython suite and upstream CI have not been run.

Fixes #160071.

Signed-off-by: Casper Verbuyst <casperverbuyst@gmail.com>
Signed-off-by: Casper Verbuyst <casperverbuyst@gmail.com>
@python-cla-bot

python-cla-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Lib/test/test_gzip.py Outdated
Comment thread Lib/test/test_gzip.py Outdated
repzakske and others added 2 commits October 21, 2026 20:56
Co-authored-by: Neko Asakura <neko.asakura@outlook.com>
Signed-off-by: Casper Verbuyst <casperverbuyst@gmail.com>
@repzakske
repzakske requested a review from NekoAsakura October 21, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GzipFile.seek() returns a stale position when writing buffered padding

2 participants