tmax: decode taxonomy.json and template_prompt.md as UTF-8 - #141
Open
KNambiarDJsc wants to merge 1 commit into
Open
KNambiarDJsc wants to merge 1 commit into
KNambiarDJsc wants to merge 1 commit into
Conversation
Both are read via importlib.resources.files(...).read_text() with no explicit encoding, so Python falls back to the locale's preferred encoding. On Windows that's cp1252, not UTF-8, and template_prompt.md's prose contains bytes cp1252 can't map (e.g. a right single quotation mark), crashing every call with UnicodeDecodeError. Same bug class as huggingface#115, different call shape (importlib.resources vs subprocess) so outside that PR's scope.
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.
Summary
Another item from the #130 Windows-portability triage:
tmax.sampler.template_prompt()reads two package data files viaimportlib.resources.files(...).read_text()with no explicit encoding, so Python falls back to the locale's preferred encoding —cp1252on Windows, not UTF-8.template_prompt.md's prose contains bytescp1252can't decode (a right single quotation mark, byte0x9d), so every call crashes:This is the same bug class fixed in #115 (locale-default text decoding), but a different call shape —
importlib.resources.files().read_text()rather thansubprocess(text=True, ...)— so it was outside that PR's scope and got missed.Scoped narrowly to the two calls in this function; a repo-wide sweep of every
.read_text()/.write_text()call is a much bigger, separate change and most of those sites only ever round-trip the tool's own generated JSON/TOML (never non-ASCII prose), so they're not exhibiting this failure mode.Test plan
uv run pytest tests/test_tmax_recipe.py::test_taxonomy_sampling_is_repeatable_and_preserves_legacy_axes -q— now passes (was failing withUnicodeDecodeErroron Windows)uv run ruff check/ruff format --checkon the touched file