← Back to Pull requests

Support stored archive writes with zipfile #4973

Closed
unknown closed this pull request without merging on Nov 03, 2026 19:14 UTC
View on GitHub
unknown unknown commented on Nov 03, 2026 15:20 UTC
Author

Summary

Bundle CPython 3.14.5’s zipfile package for stored archive writes. Runtime callers can create a ZIP, list its members and read their bytes back. The compiler keeps the native path for supported read-only calls and exposes the five compression constants as integers. The runtime also exposes random.randint and random.randbytes, which the upstream test module imports. The compiler uses the runtime implementation of randbytes only when the program needs it. An unused import or a call to randbytes(5) preserves the type error at an unrelated typed("wrong") call.

The bundled zlib has no streaming compressor. Previously a DEFLATE write could truncate an existing archive, damage a stored member’s central-directory entry, or leave an open writer during exception cleanup. Check for compressobj before opening a write destination or modifying a supplied ZipInfo.

Verification

On checked Linux O0 and O3, the stored-archive CLI and the unavailable-writer regression passed. Rejected writes left existing bytes and member metadata intact. Absent paths stayed absent in w, x and a modes. A subsequent stored write succeeded, both members reopened, and the descriptor count returned to baseline. Owned and borrowed readers, malformed archives and repeated extraction matched stock at all 15 descriptor checkpoints. A typed reader checked ZipInfo.compress_type == ZIP_DEFLATED and read a stock-compressed member three times, with three closes.

Ordinary discovery on this branch registers 54 path methods and the stock optional big_o skip. The core module stops at its Shift JIS class fixture. The separate codec change in #4996 allows the package loader to register all 379 pinned entries in order in the combined check. The upstream path checks cover TestPath.test_pickle and TestPath.test_read_does_not_close. Native DEFLATE and Zstandard writing remain outside this implementation.

<details>
<summary>Source provenance</summary>

Three package files match their pinned CPython blobs and one has an Imre-specific change. All four paths are relative to Lib/zipfile upstream and crates/imre-compiler/stdlib/zipfile here.

| File | CPython blob | Imre blob |
| --- | --- | --- |
| __init__.py | c8d8d3a2c0a5b30dfd9ff1e3b82609c6087743b0 | 5669438c73733eaf42bdd555d90df26654fed003 |
| __main__.py | 868d99efc3c4a317b869b9bfc30a0ccf857ca73e | Same |
| _path/__init__.py | 80f5d607731fd78a3706f1be1885b4dc30ded7c9 | Same |
| _path/glob.py | bd2839304b7db2a628c7d3785f1d0a0d316424f8 | Same |

The initializer delta is +20/−8 lines. The other ten changed paths cover runtime import registration, compiler ZIP dispatch and constants, runtime random support, and the CLI, import-checker and runtime regression fixtures. Pinned upstream package

</details>

Diff: 363 lines (+272 / -91) across 4 files Reviewer: charliermarsh Review duration: 233m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 363 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
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
Diff Size diff_size
0.353
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4973"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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: 42.7% (MEDIUM) · Higher = larger blast radius
42.7%
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: 60.5% · Lower = rushed or shallow review
60.5%
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: 16.9% · Safe to merge
16.9%