Repository navigation
🐛 fix(activation): preserve Tcl/Tk and xonsh paths across codecs - #3743
Merged
gaborbernat merged 2 commits intoNov 20, 2026
Merged
Conversation
Tcl library paths and Xonsh activation values could change when a script was sourced under a different text or filesystem codec. Check recorded Tcl bytes, emit encoding-independent Xonsh source, and refuse path text that cannot round-trip through the active filesystem codec. Refs pypa#3743 Refs pypa#3708 Refs pypa#3709 Refs pypa#3729 Refs pypa#3717
gaborbernat
force-pushed
the
restore/3645-tcl-library-codec
branch
from
November 20, 2026 15:31
a252d6f to
b99286a
Compare
gaborbernat
marked this pull request as ready for review
November 20, 2026 17:27
gaborbernat
marked this pull request as draft
November 20, 2026 20:27
Validate the next environment's path while the current environment is still active. A Big5 session can then keep using its interpreter when it cannot represent the destination.
gaborbernat
marked this pull request as ready for review
November 20, 2026 21:28
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.
Activation templates copied Tcl library path text into generated scripts without checking whether its UTF-8 spelling matched the original path bytes. Xonsh activation could also reinterpret path or prompt text under a different source or filesystem codec. The generated scripts now preserve verifiable library paths and reconstruct Xonsh values without changing their path bytes. This addresses draft advisories ANT-2026-174OWDGY and ANT-2026-Y91OJFTQ.
Tcl and Tk library paths
Python discovery reads Tcl's reported library path, and Tcl consults
TCL_LIBRARYfor its startup library. In a legacy POSIX locale, the reported text can differ from the environment variable's original bytes. During script generation, the shared activation check includes a non-ASCII Tcl or Tk path only when its UTF-8 bytes match the current variable. ASCII paths and Windows paths keep their prior behavior. If the bytes cannot be verified, sourcing the script leaves the shell's existing library value alone.Xonsh source and filesystem codecs
The Xonsh template renders prompts and other text that could change meaning under UTF-7 source decoding as ASCII expressions. On POSIX it records non-ASCII environment and library paths as UTF-8 bytes. The sourced activator decodes those paths with the active filesystem codec and checks that they round-trip. This keeps
VIRTUAL_ENV,PATH,PKG_CONFIG_PATH, Tcl and Tk values, and the prompt tied to the intended environment across the tested codec changes.Behavior changes
An existing non-ASCII
TCL_LIBRARYfrom a matching UTF-8 environment remains available after activation. If its source bytes cannot be verified, activation leaves it alone. Tcl uses its normal search when the variable is unset. The same check applies toTK_LIBRARY, including a Tk path derived from a verified Tcl source. If the Xonsh filesystem codec cannot represent the destination, activation fails and the current environment stays active. Xonsh omits optional library paths it cannot verify. Existing environments need recreated activation scripts to receive these changes.Fixes #3631. Reported by oss-scanner: ANT-2026-174OWDGY, ANT-2026-PQW92I38, ANT-2026-Y91OJFTQ.