Skip to content

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

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.

@arhadthedevarhadthedev added OS-windows stdlib Standard Library Python modules in the Lib/ directory labels Apr 2, 2023
@arhadthedevarhadthedev 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
arhadthedev requested a review from a teamApril 2, 2023 03:58
Comment threadLib/shutil.py Outdated
Comment threadLib/shutil.py Outdated
Comment threadLib/shutil.py Outdated
Comment threadLib/shutil.py Outdated
Comment threadLib/shutil.py Outdated
@csm10495

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadLib/shutil.py Outdated
csm10495and others added 2 commits April 2, 2023 15:36
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Comment threadLib/shutil.py Outdated
Comment threadLib/test/test_shutil.py Outdated
Comment threadLib/test/test_shutil.py Outdated
csm10495and 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>
@eryksuneryksun added the 3.12 only security fixes label Apr 2, 2023
Comment threadLib/shutil.py Outdated
csm10495and others added 2 commits April 4, 2023 13:16
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@csm10495

Copy link
Copy Markdown
ContributorAuthor

@zooba updated and added a corresponding test.

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

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

Copy link
Copy Markdown
ContributorAuthor

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 threadDoc/library/shutil.rst Outdated
@csm10495

Copy link
Copy Markdown
ContributorAuthor

@eryksun added. Thanks.

@eryksuneryksun 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.

LGTM. Thank you, Charles.

@vstinner

Copy link
Copy Markdown
Member

This change introduced a regression: #127001.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12only security fixesOS-windowsstdlibStandard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@csm10495@eryksun@zooba@vstinner@arhadthedev@bedevere-bot