← Back to Pull requests

gh-160000: Fix LZMADecompressor raising on repeated empty decompress calls #160205

Open
unknown opened this pull request with 149 lines diff across 1 files
View on GitHub
unknown unknown commented on Oct 22, 2026 05:30 UTC
Author

Fixes #160000.

LZMADecompressor.decompress(b'', max_length=0) works once, then raises LZMAError: Insufficient buffer space on the second call. Same after real input when output is pending internally.

In Modules/_lzmamodule.c, decompress_buf treats LZMA_BUF_ERROR from liblzma as benign only when avail_in == 0 and avail_out > 0. With max_length=0 there is no output space, so that check never fires for the empty call, and the error escapes. The fix treats it as benign when avail_in == 0 or avail_out == 0. That is safe because the avail_out == 0 branch 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.py covering 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_lzma passes (125 tests), the issue repro returns b'' on repeated calls, the decompressor stays usable afterwards, and corrupt input still raises LZMAError.

Note: this is my first CPython PR, I will complete the CLA check when prompted.

<!-- gh-issue-number: gh-160000 -->

  • Issue: gh-160000

  • <!-- /gh-issue-number -->

    Diff: 149 lines (+111 / -38) across 1 files Reviewer: pganssle Review duration: 58653m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.0% (MEDIUM) · Higher = larger blast radius
    40.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.6% · Safe to merge
    23.6%
    Repository