← 返回首页
GH-75586: Fix case where PATHEXT isn't applied to items in PATH (Windows) by csm10495 · Pull Request #103179 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

GH-75586: Fix case where PATHEXT isn't applied to items in PATH (Windows)#103179

Merged
zooba merged 31 commits into
python:mainfrom
csm10495:fix_which_pathext_windows
Apr 4, 2023
Merged

GH-75586: Fix case where PATHEXT isn't applied to items in PATH (Windows)#103179
zooba merged 31 commits into
python:mainfrom
csm10495:fix_which_pathext_windows

Conversation

csm10495 commented Apr 2, 2023

Copy link
Copy Markdown
Contributor

GH-75586 - Fix case where PATHEXT isn't applied to items in PATH.

The logic change here makes it so that if the command passed into shutil.which on windows, it will be verified against how it is passed in and against the various items in PATHEXT.

For example:

shutil.which('C:/windows/system32/cmd')

will now return

'C:/windows/system32/cmd.EXE'

Instead of None.

If this looks good, I'd be happy to create a changelog entry, etc. Just feeling the water with this first commit.

arhadthedev added OS-windows stdlib Standard Library Python modules in the Lib/ directory labels Apr 2, 2023
arhadthedev changed the title GH-75586 - Fix case where PATHEXT isn't applied to items in PATH (Win… GH-75586: Fix case where PATHEXT isn't applied to items in PATH (Windows) Apr 2, 2023
arhadthedev requested a review from a team April 2, 2023 03:58
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved

csm10495 commented Apr 2, 2023

Copy link
Copy Markdown
Contributor Author

@eryksun I think i fixed everything. Check again. Thanks!

Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
csm10495 and others added 2 commits April 2, 2023 15:36
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/test/test_shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/test/test_shutil.py Outdated Show resolved Hide resolved
csm10495 and others added 2 commits April 2, 2023 16:10
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
eryksun added the 3.12 only security fixes label Apr 2, 2023
37 hidden items Load more…
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
Comment thread Lib/shutil.py Outdated Show resolved Hide resolved
csm10495 and others added 2 commits April 4, 2023 13:16
Co-authored-by: Steve Dower <steve.dower@microsoft.com>

csm10495 commented Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

@zooba updated and added a corresponding test.

csm10495 requested a review from zooba April 4, 2023 20:27

zooba commented Apr 4, 2023

Copy link
Copy Markdown
Member

Looks good, and the tests all patch the call to that API so we shouldn't be impacted if the test machine has it configured differently.

Once CI passes, and unless someone else speaks up, I'll merge. Thanks for all your work on this!

csm10495 commented Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

Got a doctest failure... The error is odd.. maybe its transient? I'll push an empty commit to see if it helps.

Testing of doctests in the sources finished, look at the results in build/doctest/output.txt. python: ./Include/internal/pycore_typeobject.h:75: _PyType_GetModuleState: Assertion `et->ht_module' failed. Aborted (core dumped) make[1]: *** [Makefile:49: build] Error 134 make[1]: Leaving directory '/home/runner/work/cpython/cpython/Doc' Testing of doctests in the sources finished, look at the results in build/doctest/output.txt make: *** [Makefile:127: doctest] Error 1 make: Leaving directory '/home/runner/work/cpython/cpython/Doc' Error: Process completed with exit code 2.

Comment thread Doc/library/shutil.rst Outdated Show resolved Hide resolved

csm10495 commented Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

@eryksun added. Thanks.

eryksun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

LGTM. Thank you, Charles.

Copy link
Copy Markdown
Member

This change introduced a regression: #127001.

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

Labels

3.12 only security fixes OS-windows stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Footer

© 2026 GitHub, Inc.