Skip to content

[3.14] gh-157917: Do not leak the \\?\ extended-length prefix into sys.prefix on Windows venvs (GH-158465) - #162062

Merged
vsajip merged 1 commit into
python:3.14from
miss-islington:backport-c4f4928-3.14
Nov 15, 2026
Merged

vsajip merged 1 commit into
python:3.14from
miss-islington:backport-c4f4928-3.14

Conversation

@miss-islington

@miss-islington miss-islington commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

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

….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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants