4 Commits
Author SHA1 Message Date
Jean-Marc Le Roux 3805038dec zlib: clear unconsumed_tail when a bounded decompress reaches stream end (#8908)
* zlib: clear unconsumed_tail when a bounded decompress reaches stream end

When a max_length-bounded Decompress.decompress() call reached the end
of the stream, the bytes after the stream went to unused_data, but
unconsumed_tail kept the previous call's tail, including input the call
had already consumed. A later flush() then moved those stale bytes into
unused_data.

Empty unconsumed_tail at end of stream, as CPython's
save_unconsumed_input() does since gh-158169. CPython releases before
that change report the bytes after the stream in unconsumed_tail, so
the snippet accepts either value when it runs under CPython.

Fixes #8906

Assisted-by: Claude Code:claude-opus-5-5

* zlib: bind the unconsumed input with an if expression

Choose between the empty slice and the rest of the input in one
expression instead of reassigning a mutable binding.

Assisted-by: Claude Code:claude-opus-5-5

* zlib: accept both valid tails in the snippet on every implementation

The snippet no longer branches on sys.implementation. RustPython and
CPython after gh-158169 give an empty tail; CPython before it gives the
bytes after the stream. The stale tail of gh-8906 fails either way.

Assisted-by: Claude Code:claude-opus-5-5
2026-09-30 22:15:40 +09:00
Shahar Naveh 9ccf4c1872 Ruff auto-format (#6422) 2025-12-12 22:46:39 +09:00
Jeong YunWon e96dd96864 Refactor zlib and add wbits to zlib.compress() 2023-03-15 23:52:51 +09:00
Jeong YunWon e62a164f4d Move tests -> extra_tests 2020-09-13 06:58:57 +09:00