Repository navigation
[3.14] gh-157917: Do not leak the \\?\ extended-length prefix into sys.prefix on Windows venvs (GH-158465) - #162062
Merged
Conversation
….prefix on Windows venvs (pythonGH-158465) When a venv interpreter is invoked through a "\\?\" extended-length path, the venv launcher reports its own path via GetModuleFileNameW, which preserves that prefix. getpath.py consumed the value verbatim, so sys.prefix, sys.exec_prefix and sys.executable all kept the prefix. Windows does not resolve ".." or any other relative component in an extended-length path, so tools that join them onto a sysconfig path break. That is what makes "pip install" of a wheel with a "scripts=" entry fail with "OSError: [Errno 22] Invalid argument". Strip the prefix back off the launcher-provided path on Windows. A path that would still exceed MAX_PATH once unprefixed keeps the prefix, since the extended-length form is the only usable one for it. (cherry picked from commit c4f492884ae211a286911318a9486b6d7aee64f1) Co-authored-by: Abhinav <alpha9coder@gmail.com>
This was referenced Nov 15, 2026
Merged
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.
When a venv interpreter is invoked through a "\?" extended-length path, the
venv launcher reports its own path via GetModuleFileNameW, which preserves
that prefix. getpath.py consumed the value verbatim, so sys.prefix,
sys.exec_prefix and sys.executable all kept the prefix.
Windows does not resolve ".." or any other relative component in an
extended-length path, so tools that join them onto a sysconfig path break.
That is what makes "pip install" of a wheel with a "scripts=" entry fail with
"OSError: [Errno 22] Invalid argument".
Strip the prefix back off the launcher-provided path on Windows. A path that
would still exceed MAX_PATH once unprefixed keeps the prefix, since the
extended-length form is the only usable one for it.
(cherry picked from commit c4f4928)
Co-authored-by: Abhinav alpha9coder@gmail.com
venvon Windows preserves the\\?\extended-length path prefix insys.prefixon 3.14, unlike 3.10 - breaks tools that join sysconfig paths with relative (..) components #157917