decompress_chunks reports whether the codec signalled LZMA_STREAM_END,
and it short-circuits when the chunker has nothing left to feed. That
early return answered "the stream ended" for the case where no input was
supplied at all, so LZMADecompressor.decompress(b"") claimed a finish the
decoder had never signalled.
The caller latches that answer with `self.eof |= stream_end`, which only
ever flips eof on. A single empty call therefore finished the object for
good: needs_input went false and every later call was rejected by the
`if self.eof` guard with EOFError, before a single compressed byte had
been seen. CPython leaves eof false and needs_input true, and accepts
compressed data handed over by a later call.
d = lzma.LZMADecompressor()
d.decompress(b"") # d.eof was True, now False
d.decompress(blob) # was EOFError, now b'data'
The zlib engine returns false from the same short-circuit; lzma had
drifted away from it. bz2 was fixed incidentally by #8638 when its engine
moved into crates/common, so only lzma needed a code change.
Verified on macOS arm64 against CPython 3.14.7: the script from the issue
now prints the documented "False True" and b'data' for both
decompressors. test_decompressor_chunks_empty in Lib/test/test_lzma.py
covers exactly this and no longer needs its expectedFailure marker. The
added engine test is named after the zlib one that already existed and is
mirrored into bz2, so all three engines stay pinned to the same
behaviour. test_lzma, test_bz2, test_zlib, test_gzip, test_tarfile,
cargo test --workspace, cargo fmt --check and cargo clippy
-p rustpython-common --all-features --all-targets -D warnings are clean.
Fixes#8637
Assisted-by: Claude Code:claude-opus-5
This directory contains all of the Python files that make up the standard
library for RustPython.
Most of these files are copied over from the CPython repository (the 3.7
branch), with slight modifications to allow them to work under RustPython. The
current goal is to complete the standard library with as few modifications as
possible. Current modifications are just temporary workarounds for bugs/missing
feature within the RustPython implementation.
The first big module we are targeting is unittest, so we can leverage the
CPython test suite.