tooling: normalize malformed zlib errors in paged resource reader #462
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/468"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-22T05:28:35Z.
## Change
In
tools/paged_resource.py,PagedResource.read()enforces size budgets, boundary checks, and decoded extent matching by raisingValueErroron malformed segments. However, if a segment contains corrupted compressed bytes (e.g. invalid zlib header or illegal compression method),decoder.decompress()raised an unhandledzlib.errordirectly out of the reader.This change:
decoder.decompress()withtry ... except zlib.error as exc:and raisesValueError("Invalid compressed segment or decoded extent") from exc, normalizing compressed corruption to the reader's standardValueErrorcontract.tests/resource_ranges_check.py, adds an intact control test ensuring valid decompression continues to succeed, and adds a synthetic corrupted zlib payload test (b"not zlib") verifyingValueError("Invalid compressed segment or decoded extent")is raised instead ofzlib.error.Verification
Run on Windows x64 with Python 3.14 (
D:\Xbox2Windows\.venv\Scripts\python.exe):Output:
Full platform-independent suite (20 checks including
docs_links_check.pyandbidi_controls_check.py):Result: All 20 checks passed with exit code 0.
Evidence and follow-up
All fixtures are in-memory byte streams created with
io.BytesIOand Python's standardzlib.compress.This change is AI-assisted.
Checklist