8000 gh-109590 - Update shutil.which on win32 to only give back PATHEXT matches by default by csm10495 · Pull Request #109995 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109590 - Update shutil.which on win32 to only give back PATHEXT matches by default #109995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove casefold since it doesn't exist on bytes (and the code needs t…
…o work with str and bytes)
  • Loading branch information
csm10495 committed Sep 29, 2023
commit d93e51febef5bae07d03139384b8898b5b67569b
4 changes: 2 additions & 2 deletions Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,8 +1560,8 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
# for a PATHEXT match. The first cmd is the direct match
# (e.g. python.exe instead of python)
# Check that direct match first if and only if the extension is in PATHEXT
suffix = os.path.splitext(files[0])[1].casefold()
if mode & os.X_OK and not any(suffix == ext.casefold() for ext in pathext):
suffix = os.path.splitext(files[0])[1].upper()
if mode & os.X_OK and not any(suffix == ext.upper() for ext in pathext):
del files[0]
else:
# On other platforms you don't have things like PATHEXT to tell you
Expand Down
0