fix: write wheel METADATA as UTF-8 - #138
Draft
aiolibsbot wants to merge 1 commit into
Draft
Conversation
Path.write_text() uses the locale-default encoding when no encoding is passed. On systems with a non-UTF-8 default (e.g. LC_ALL=C and PYTHONUTF8=0), a wheel whose METADATA contains non-ASCII characters (author names, descriptions) raises UnicodeEncodeError and aborts the indexer. Force encoding="utf-8" — METADATA is defined as UTF-8 per the wheel spec, and we already read it as text via dist_meta. Adds a regression test that round-trips a metadata payload with non-ASCII characters. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Force `encoding="utf-8"` when writing the extracted METADATA file in `WheelFile.from_wheel`.
Why
`Path.write_text(s)` falls back to the locale-default encoding. With `LC_ALL=C` and `PYTHONUTF8=0` (still common in minimal container images and some CI runners), any wheel whose METADATA contains non-ASCII characters — accented author names, em-dashes, curly quotes in descriptions — raises `UnicodeEncodeError` and aborts the entire index build. The wheel spec defines METADATA as UTF-8, so the indexer should write it that way unconditionally.
How
Testing
`pytest tests/` — 15/15 pass.
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 25 insertions(+), 2 deletions(-)
Code scan: clean
Tests: failed (command not found)
Branch hygiene: 1 issue(s)
Generated by Kōan post-mission quality pipeline