-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
gh-109590 - Update shutil.which on win32 to only give back PATHEXT matches by default #109995
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor code changes, but overall it looks good to me
Updated with suggestions. I think we're ready for a merge. Thanks! |
grr.. accidental pull.. sorry to the folks who got added by mistake. Fixed it but it still added y'all. @zooba i went back to |
…EXT matches by default
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
…o work with str and bytes)
fd3a830
to
d93e51f
Compare
I wonder if we ought to keep the extensionless file at the end? That should help preserve people who really do want the extensionless file returned, and are currently succeeding (even in older versions I believe) if there's no executable there. So our language becomes "shutil.which prefers files with a PATHEXT extension when an executable path is requested" (I'll rewrite the commit message on merge, don't worry about trying to do it, but wanted to let you know what it'll be) |
@zooba I gave it a try. Let me know what ya think. Thanks again. Feel free to squash, rewrite the message, etc. |
Looks great! More updates than I thought, I'm glad I clarified the language for you 😄 |
…xtension on executable files (pythonGH-109995) The default arguments for shutil.which() request an executable file, but extensionless files are not executable on Windows and should be ignored. (cherry picked from commit 29b875b) Co-authored-by: Charles Machalow <csm10495@gmail.com>
GH-110202 is a backport of this pull request to the 3.12 branch. |
…extension on executable files (GH-109995) (#110202) gh-109590: Update shutil.which on Windows to prefer a PATHEXT extension on executable files (GH-109995) The default arguments for shutil.which() request an executable file, but extensionless files are not executable on Windows and should be ignored. (cherry picked from commit 29b875b) Co-authored-by: Charles Machalow <csm10495@gmail.com>
…xtension on executable files (pythonGH-109995) The default arguments for shutil.which() request an executable file, but extensionless files are not executable on Windows and should be ignored.
Based off the conversation in gh-109590, if os.X_OK, only give back things that match PATHEXT. Add some corresponding tests.
@zooba said this should probably be in a 3.12.1, so I've marked it that way, though I'm not sure what else I need to change to aim for that. Please advise. Thanks.
Also updated the
which
tests to work a bit cleaner in terms ofstr
vsbytes
. Previously a decent amount of testing wasn't actually running asbytes
.📚 Documentation preview 📚: https://cpython-previews--109995.org.readthedocs.build/