Skip to content

🐛 fix(activate): preserve Tcl and Tk paths - #3660

Merged
gaborbernat merged 6 commits into
pypa:mainfrom
gaborbernat:fix/tcl-library-followup-174
Nov 20, 2026
Merged

gaborbernat merged 6 commits into
pypa:mainfrom
gaborbernat:fix/tcl-library-followup-174

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR #3645 verified Tcl library bytes when generating activation scripts, but its Xonsh script still embedded a Unicode literal. Sourcing that script under a different POSIX locale could export different path bytes. Xonsh now reconstructs the verified bytes with its active filesystem codec. The follow-up also restores non-ASCII Tk paths derived from a verified Tcl source. This follows draft advisory ANT-2026-174OWDGY.

Xonsh activation across locales

Xonsh's ASCII literal quoting kept the generated script readable, but preserved the path as Unicode text. A later legacy locale could encode that text to different bytes on export. The new substitution embeds the UTF-8 bytes verified during generation and decodes them when sourced, using the active filesystem codec. ASCII paths and Windows Unicode paths retain their earlier rendering.

flowchart LR
    V[Verified UTF-8 path bytes] --> O[Old Xonsh Unicode literal]
    O --> M[Later locale may export different bytes]
    V --> N[New bytes literal]
    N --> D[Decode with active filesystem codec]
    D --> S[Export original bytes]
    classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000;
    classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;
    class O,M bad;
    class N,D,S ok;
Loading

Derived Tk paths

Python-discovery can derive a Tk library path from Tcl when TK_LIBRARY is unset. The merged check dropped non-ASCII derived paths in that case. The follow-up retains one when the raw TCL_LIBRARY bytes match the recorded Tcl path and the derived Tk path encodes to the same UTF-8 bytes that the script will write. An explicit TK_LIBRARY still requires its own byte match.

GraalPy FIFO test gate

PR #3662 found that GraalPy does not expose os.mkfifo, so the FIFO metadata test failed before reaching its assertions. This branch includes its capability guard, allowing the test to run on interpreters that provide FIFOs and skip where they are unavailable. The combined branch lets the GraalPy and PyPy suites check the Tcl fix without either merged regression blocking the other.

Test coverage

A Xonsh subprocess test checks the exported TCL_LIBRARY bytes after activation in a C locale. Windows generation checks that non-ASCII Tcl and Tk paths remain Unicode literals; I also ran it with legacy filesystem encoding in the Windows VM. The Tcl discovery integration test from #3645 now runs only on CPython: PyPy reports its bundled Tcl library path rather than the test's temporary TCL_LIBRARY directory, which caused the PyPy 3.11 CI failure.

Reported by oss-scanner: ANT-2026-174OWDGY.

@gaborbernat gaborbernat added security Fixes a vulnerability or hardens the supply chain, CI or release bug labels Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 06:34
@gaborbernat gaborbernat changed the title 🐛 fix(xonsh): preserve Tcl bytes across locales 🐛 fix(activate): preserve Tcl and Tk paths Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 06:48
@gaborbernat
gaborbernat merged commit 6a90395 into pypa:main Nov 20, 2026
87 of 88 checks passed
@gaborbernat
gaborbernat deleted the fix/tcl-library-followup-174 branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant