gh-160000: Fix LZMADecompressor raising on repeated empty decompress calls #160205
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.40) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 149 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.300
Real PR Conversation Timeline
1 comments
"Review active on #160205"
general
weight: 0.35
pganssle
Fixes #160000.
LZMADecompressor.decompress(b'', max_length=0)works once, then raisesLZMAError: Insufficient buffer spaceon the second call. Same after real input when output is pending internally.In
Modules/_lzmamodule.c,decompress_buftreatsLZMA_BUF_ERRORfrom liblzma as benign only whenavail_in == 0andavail_out > 0. Withmax_length=0there is no output space, so that check never fires for the empty call, and the error escapes. The fix treats it as benign whenavail_in == 0oravail_out == 0. That is safe because theavail_out == 0branch either breaks once the requested length is reached or grows the buffer, so it cannot spin.Also adds a regression test in
Lib/test/test_lzma.pycovering the empty case and the after-real-input case, and a NEWS entry.Verified by building CPython from main and running the test suite:
test_lzmapasses (125 tests), the issue repro returnsb''on repeated calls, the decompressor stays usable afterwards, and corrupt input still raisesLZMAError.Note: this is my first CPython PR, I will complete the CLA check when prompted.
<!-- gh-issue-number: gh-160000 -->
<!-- /gh-issue-number -->