Support stored archive writes with zipfile #4973
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
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
charliermarsh
Summary
Bundle CPython 3.14.5’s
zipfilepackage 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 exposesrandom.randintandrandom.randbytes, which the upstream test module imports. The compiler uses the runtime implementation ofrandbytesonly when the program needs it. An unused import or a call torandbytes(5)preserves the type error at an unrelatedtyped("wrong")call.The bundled
zlibhas 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 forcompressobjbefore opening a write destination or modifying a suppliedZipInfo.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,xandamodes. 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 checkedZipInfo.compress_type == ZIP_DEFLATEDand read a stock-compressed member three times, with three closes.Ordinary discovery on this branch registers 54 path methods and the stock optional
big_oskip. 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 coverTestPath.test_pickleandTestPath.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/zipfileupstream andcrates/imre-compiler/stdlib/zipfilehere.| 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>