Skip to content

🐛 fix(activation): bind pydoc to env Python - #3732

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/pydoc-batch-python-3616
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/pydoc-batch-python-3616

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The Windows pydoc.bat launcher called a bare python.exe. Calling it by full path before activating the environment could therefore run another Python from PATH. It now calls the interpreter beside the launcher. Fixes #3616.

The batch file handles full paths and quoted batch filenames, including paths with spaces. An environment directory's literal ! characters survive delayed expansion inside the launcher. When passing a full path to the launcher, the caller must also preserve the literal ! characters. It passes the user's arguments to python -m pydoc and preserves the interpreter's normal current-directory module lookup. See Windows batch path expansion.

Reported by oss-scanner: ANT-2026-76IHL4HB.

cmd.exe can expand %~dp0 to the caller's directory when a quoted pydoc
name is resolved through PATH. Resolve it in a called label so both
PATH lookups and direct calls use the environment's Python.

Fixes pypa#3616
@gaborbernat
gaborbernat force-pushed the fix/pydoc-batch-python-3616 branch from 3d7996c to 84fca3f Compare November 20, 2026 15:33
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 18:20
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 20:27
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 21:19
@gaborbernat
gaborbernat merged commit 717380f into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/pydoc-batch-python-3616 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows pydoc.bat can use the wrong Python

1 participant