Repository navigation
🐛 fix(xonsh): retain environment path bytes - #3729
Closed
gaborbernat wants to merge 37 commits into
Closed
gaborbernat wants to merge 37 commits into
gaborbernat wants to merge 37 commits into
Conversation
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Pin the pre-commit hook to [simplint 0.14.2](https://github.com/gaborbernat/simplint/releases/tag/0.14.2). This release starts larger files earlier during parallel checks and sizes cache reads to the archive on disk. Give bare `Final` annotations explicit types across virtualenv, maintenance tasks and tests. The wheel installer also declares its lazy `posixpath` import. Refresh the CodeQL mutant patches for the new annotations. The macOS GraalPy reseeding test timed out while uninstalling pip. Collect each package directory once when cleaning up files from pip's RECORD. The test also uses the existing fixture that keeps coverage out of pip's subprocesses.
…3588) Co-authored-by: Bernát Gábor <[email protected]>
Co-authored-by: Bernát Gábor <[email protected]>
…pypa#3591) Co-authored-by: Bernát Gábor <[email protected]>
Co-authored-by: Bernát Gábor <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Complete the cache creation fix from pypa#3642.
Preserve Tcl and Tk paths across UTF-7 Xonsh activation.
EnvBuilder writes activation scripts before virtualenv applies the selected activators. A fresh environment could therefore retain an unselected script that sources destination path text as shell code. Remove the stdlib scripts before writing virtualenv's selected scripts.
An interrupt could let session cleanup remove temporary app-data while a seed worker still used it. Wait for active lookups and installations before propagating the interrupt so cleanup runs after they finish. Fixes pypa#3636
Delayed expansion in cmd.exe changed literal exclamation marks in saved PATH entries. Read and restore those values according to the shell mode at each activation step so entries round-trip if the mode changes. Fixes pypa#3617
site.addsitedir executes environment .pth hooks before the old script moved environment paths ahead of host paths. Put interpreter and environment paths first while those hooks run, then retain their path additions after activation. Fixes pypa#3623
CPython 3.14 searches upward from a copied libpython for its standard library. A writable sibling library directory could redirect startup in a private copy-mode environment. Check that search location before copying the library and keep the copy needed by relative loader paths.
Without HOME or a passwd entry, platformdirs can leave the default home path unresolved. Configuration and cache lookup then use paths under the invoking tree. Skip the default configuration and use temporary app-data when no absolute default cache path exists. An explicit path remains available.
A migrated default cache could expose group-writable wheel files through a traversable root. Restrict the root before moving or copying its descendants. Setgid caches retain group access while other accounts lose access.
Under a non-UTF-8 POSIX locale, seeded pip launchers could spell the interpreter path with different bytes and fail to start. Use an ASCII shell wrapper with octal escapes when the path's filesystem bytes differ from UTF-8; keep direct shebangs otherwise. Fixes pypa#3632
Xonsh re-encodes the embedded destination with its session's filesystem codec. After creation under UTF-8, activation under another codec could name a different directory in PATH. Record the destination bytes and decode them in the sourcing session, as the Tcl and Tk paths already do. Fixes pypa#3631
gaborbernat
added a commit
to gaborbernat/virtualenv
that referenced
this pull request
Nov 20, 2026
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
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.
The Xonsh activation script embedded the destination as Unicode. An environment created under UTF-8 could then activate a different byte-spelled directory when Xonsh ran under ISO-8859-1, putting that directory first on
PATH. The script now records non-ASCII destination paths as bytes and decodes them in the sourcing session. Fixes #3631.Xonsh re-encoded the destination
Python converts environment paths using the process filesystem codec. At generation time,
ActivationSelector.createpermits shell scripts only when the destination's filesystem bytes match its UTF-8 encoding. For non-ASCII paths, the Xonsh substitution now embeds those bytes for__VIRTUAL_ENV__as it already did for Tcl and Tk paths.os.fsdecodegives the sourcing session a string that encodes back to the original bytes.Behavior changes
On POSIX, Xonsh activation keeps the created destination in
VIRTUAL_ENV,PATH, andPKG_CONFIG_PATHwhen the sourcing session uses another filesystem codec. Windows continues to embed the Unicode path. Existing environments need their activation scripts regenerated to receive the fix.Reported by oss-scanner: ANT-2026-PQW92I38.
Replaces #3671 after its merge was reverted.