Skip to content

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

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

gaborbernat merged 4 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 python.exe without a directory. When someone called the batch file by full path without activating the environment, it could document packages from another Python on PATH. The launcher now uses the environment's interpreter. Fixes #3616.

The batch launcher chose Python from PATH

Windows looks up a bare executable name in the current directory and PATH. The launcher now uses %~dp0 to name its neighboring interpreter; batch parameter expansion supplies the batch file's drive and path. The path remains quoted, retaining the path-with-spaces behavior introduced in b9431497.

Behavior changes

A full-path call to an unactivated environment's pydoc.bat now runs that environment's Python even when another Python comes first on PATH. The launcher still passes arguments to python -m pydoc, including its normal current-directory module lookup.

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

@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 06:34
@gaborbernat
gaborbernat force-pushed the fix/pydoc-batch-python-3616 branch from 926f140 to 3bc840e Compare November 20, 2026 06:50
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 07:30
@gaborbernat
gaborbernat merged commit b8067f9 into pypa:main Nov 20, 2026
81 checks passed
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