Repository navigation
🐛 fix(xonsh): keep Tcl bytes in UTF-7 - #3667
Merged
Merged
Conversation
gaborbernat
force-pushed
the
fix/xonsh-tcl-utf7-174
branch
from
November 20, 2026 07:32
66c4e53 to
3cfc691
Compare
gaborbernat
marked this pull request as ready for review
November 20, 2026 08:22
This was referenced Nov 20, 2026
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.
PR #3660 kept non-ASCII Tcl library path bytes across locale changes in Xonsh, but its generated bytes literal could change when Xonsh read the script as UTF-7. The activator now writes those verified bytes as hexadecimal digits and reconstructs them when sourced. This completes the Xonsh path handling for draft advisory ANT-2026-174OWDGY.
Source decoding of embedded bytes
The previous
repr(bytes)rendering left some original ASCII path text inside the generated Python literal. UTF-7 can interpret part of that text as encoded characters before Xonsh parses the literal, changing the path bytes that activation exports. The new rendering contains only hexadecimal digits for the original path bytes. Xonsh reconstructs them with the built-inbytes.fromhexand then decodes them with its active filesystem codec, preserving the exported bytes across source and filesystem encoding changes even if the shell has a variable namedbytes.flowchart LR B[Verified path bytes] --> O[Old bytes literal with path text] O --> U[UTF-7 source decode may change text] U --> D[Different exported bytes] B --> H[New hexadecimal digits] H --> R[Reconstruct bytes at source time] R --> S[Original exported bytes] classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000; classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332; class O,U,D bad; class H,R,S ok;Behavior changes and checks
A benign Xonsh subprocess test now checks that a UTF-7 source session exports the original non-ASCII
TCL_LIBRARYbytes. The UTF-7 case fails against current main and passes with this change; the existing UTF-8 source case and a session that shadowsbytesalso pass. The same renderer handlesTK_LIBRARY. ASCII paths and Windows Unicode literals retain their previous behavior.Reported by
oss-scanner: ANT-2026-174OWDGY.