Title: zlib: return output inflate still holds after the last input byte by JMLX42 · Pull Request #8909 · RustPython/RustPython · GitHub
Open Graph Title: zlib: return output inflate still holds after the last input byte by JMLX42 · Pull Request #8909 · RustPython/RustPython
X Title: zlib: return output inflate still holds after the last input byte by JMLX42 · Pull Request #8909 · RustPython/RustPython
Description: Fixes #8907. decompress_chunks (crates/common/src/compression/zlib.rs) returned before it called inflate when the input was empty, and returned once the input was consumed even when the output buffer was full. Raw deflate has no trailer, so inflate can consume the last input byte and still hold output. Decompress.decompress(b"", n) and Decompress.flush() then returned nothing, and zlib.decompress(raw, -15, bufsize) with a small bufsize raised "incomplete or truncated stream". This mirrors CPython's zlibmodule.c: inflate runs for empty input, and runs again while it fills the output buffer. A stream with no pending output answers Z_BUF_ERROR, so an empty input or a flush() before any compressed data still leaves eof false (empty_input_does_not_finish_a_stream still passes; empty_flush_does_not_finish_a_stream is new). After a stream error, decompress(b"") now raises again, as CPython does. Tests New unit tests empty_input_returns_pending_output, flush_returns_pending_output, small_bufsize_returns_pending_output, empty_flush_does_not_finish_a_stream (the first three fail before the change). New cases in extra_tests/snippets/stdlib_zlib.py with the reproducer from #8907; they pass on RustPython and on CPython 3.13.5. rustpython-common: 135 passed; workspace: 1337 passed, 0 failed. test_zlib + test_gzip: 151 run, 4 skipped, 0 failed, before and after. test_tarfile + test_zipfile + test_shutil: 1360 run, 197 skipped, before and after. cargo fmt --check and clippy on rustpython-common are clean. #8908 (#8906) edits the same file and also appends tests at the end of mod tests; whichever merges second needs a trivial rebase. AI assistance This change was written with Claude Code (commit trailer Assisted-by: Claude Code:claude-opus-5-5). It is opened as a draft until a human has verified it, per the AI policy. 🤖 Written by Claude Code (2.1.283) using model claude-opus-5-5 Summary by CodeRabbit Bug Fixes Fixed decompression with small output buffers so remaining data can be retrieved by calling decompress again with empty input or by using flush(). Corrected stream completion reporting: pending output is no longer treated as complete, and empty input does not prematurely finish an incomplete stream. Fixed one-shot raw decompression with small buffer sizes, ensuring the full decompressed result is returned even when output is produced in small portions.
Open Graph Description: Fixes #8907. decompress_chunks (crates/common/src/compression/zlib.rs) returned before it called inflate when the input was empty, and returned once the input was consumed even when the output buff...
X Description: Fixes #8907. decompress_chunks (crates/common/src/compression/zlib.rs) returned before it called inflate when the input was empty, and returned once the input was consumed even when the output buff...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8909
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:faf9becc-ca28-10ab-0918-f06d99a1128b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AAE4:269AD9:34DEDD2:4690E09:6B020171 |
| html-safe-nonce | 2ece86247ebbf3cf8d319355373e698be4404fb2c75820430ed0bc7c50ec587d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUU0OjI2OUFEOTozNERFREQyOjQ2OTBFMDk6NkIwMjAxNzEiLCJ2aXNpdG9yX2lkIjoiMTYzNzQ3NzI2MDAxNTU2NzIxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0517dbec72192fcd930102e84a50eac38b3fd96aad88ab5e901ae51bab504f3c |
| hovercard-subject-tag | pull_request:4679657052 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/8909/files |
| twitter:image | https://avatars.githubusercontent.com/u/998703?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/998703?s=400&v=4 |
| og:image:alt | Fixes #8907. decompress_chunks (crates/common/src/compression/zlib.rs) returned before it called inflate when the input was empty, and returned once the input was consumed even when the output buff... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width