Skip to content

gh-158398: Clear unconsumed_tail at end of stream - #158408

Closed
Tony123-tech wants to merge 1 commit into
python:mainfrom
Tony123-tech:patch-1
Closed

Tony123-tech wants to merge 1 commit into
python:mainfrom
Tony123-tech:patch-1

Conversation

@Tony123-tech

@Tony123-tech Tony123-tech commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #158398.

The test test_decompress_unconsumed_tail_after_eof (added in gh-158169 / #158177) fails on main:

AssertionError: b'0123456789' != b''

Root cause: gh-158169 added self->zst.next_in += left_size; to save_unconsumed_input(), which advances next_in before the following block computes the remaining input length. This makes the computation wrong, so unconsumed_tail is not cleared at end of stream.

Changes:

  • Revert the self->zst.next_in += left_size; line.
  • Clear unconsumed_tail explicitly when Z_STREAM_END is reached.
  • Make the trailing block an else if so it is not entered at end of stream.

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.

zlib.Decompress.unconsumed_tail not cleared at end of stream (regression from gh-158169)

2 participants