Skip to content

gh-41668: Add partial data recovery support for truncated gzip streams - #160777

Open
harisawan-bit wants to merge 1 commit into
python:mainfrom
harisawan-bit:fix/gh-41668-gzip-eof
Open

harisawan-bit wants to merge 1 commit into
python:mainfrom
harisawan-bit:fix/gh-41668-gzip-eof

Conversation

@harisawan-bit

Copy link
Copy Markdown

Fixes gh-41668.

Summary of Changes

When decompressing truncated gzip archives or streams ending unexpectedly before the trailer,
eadall()\ and \decompress()\ raised \EOFError\ while discarding all decompressed blocks accumulated prior to the EOF.

This patch:

  1. Updates _streams.BaseStream.readall()\ to catch \EOFError\ on truncated reads and attach accumulated decompressed bytes as \�xc.partial_data\ before re-raising.
  2. Updates \gzip.decompress()\ with \partial=False\ by default (preserving existing exception raising semantics), while returning decompressed payload if \partial=True.
  3. Adds regression tests to \Lib/test/test_gzip.py\ validating both \partial=True\ recovery and \�xc.partial_data\ attachment.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 20:45
@python-cla-bot

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

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@StanFromIreland

Copy link
Copy Markdown
Member

We can't review unless the CLA is signed.

@StanFromIreland
StanFromIreland marked this pull request as draft October 28, 2026 09:44
@StanFromIreland StanFromIreland added awaiting review pending The issue will be closed if no feedback is provided labels Oct 28, 2026
@harisawan-bit
harisawan-bit marked this pull request as ready for review October 28, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review pending The issue will be closed if no feedback is provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle corrupted gzip files with unexpected EOF

3 participants