GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-109590 - Update shutil.which on win32 to only give back PATHEXT matches by default by csm10495 · Pull Request #109995 · python/cpython

Conversation

@csm10495

@csm10495 csm10495 commented Sep 28, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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 of str vs bytes. Previously a decent amount of testing wasn't actually running as bytes.


📚 Documentation preview 📚: https://cpython-previews--109995.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Sep 28, 2023
On Windows, shutil.which incorrectly resolves to non-executable extensionless files (python >= 3.12.0b1) #109590
Closed
@csm10495
csm10495 marked this pull request as ready for review September 28, 2023 00:32
@bedevere-app bedevere-app Bot added the awaiting review label Sep 28, 2023
zooba
zooba reviewed Sep 28, 2023
View reviewed changes

@zooba zooba left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/shutil.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/shutil.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@csm10495

csm10495 commented Sep 28, 2023

Copy link
Copy Markdown
Contributor Author

Updated with suggestions. I think we're ready for a merge. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@csm10495
csm10495 requested review from a team, 1st1, asvetlov, ezio-melotti, gvanrossum, hugovk, iritkatriel, kumaraditya303, markshannon, rhettinger and willingc as code owners September 29, 2023 00:20
@csm10495

csm10495 commented Sep 29, 2023

Copy link
Copy Markdown
Contributor Author

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 .upper() since casefold() doesn't work on bytes

zooba and willingc reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

csm10495 and others added 3 commits September 28, 2023 17:23
@csm10495
pythongh-109590 - Update shutil.which on win32 to only give back PATH…
e13eefe
…EXT matches by default
@csm10495 @zooba
Apply suggestions from code review
f5a736b
Co-authored-by: Steve Dower <[email protected]>
@csm10495
Remove casefold since it doesn't exist on bytes (and the code needs t…
d93e51f
…o work with str and bytes)
@csm10495
csm10495 force-pushed the shutil_which_no_extv3 branch from fd3a830 to d93e51f Compare September 29, 2023 00:27
@csm10495
csm10495 requested a review from zooba September 29, 2023 00:28
@gvanrossum
gvanrossum removed request for a team and gvanrossum September 29, 2023 01:20
@hugovk
hugovk removed request for a team, 1st1, iritkatriel, markshannon and rhettinger September 29, 2023 05:01
@hugovk
hugovk removed request for asvetlov, ezio-melotti, hugovk, kumaraditya303 and willingc September 29, 2023 05:01
@zooba

zooba commented Sep 29, 2023

Copy link
Copy Markdown
Member

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@csm10495
Behavior updated from pr comments
4bed27c
@csm10495

csm10495 commented Sep 30, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@zooba I gave it a try. Let me know what ya think. Thanks again.

Feel free to squash, rewrite the message, etc.

zooba reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba
zooba merged commit 29b875b into python:main Oct 2, 2023
@bedevere-app bedevere-app Bot removed the awaiting review label Oct 2, 2023
@zooba

zooba commented Oct 2, 2023

Copy link
Copy Markdown
Member

Looks great! More updates than I thought, I'm glad I clarified the language for you 😄

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba zooba added the needs backport to 3.12 only security fixes label Oct 2, 2023
@miss-islington

miss-islington commented Oct 2, 2023

Copy link
Copy Markdown
Contributor

Thanks @csm10495 for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 2, 2023
@csm10495 @miss-islington
pythongh-109590: Update shutil.which on Windows to prefer a PATHEXT e…
0090d44
…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 <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 2, 2023

Copy link
Copy Markdown

GH-110202 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 2, 2023
Yhg1s pushed a commit that referenced this pull request Oct 2, 2023
@miss-islington @csm10495
[3.12] gh-109590: Update shutil.which on Windows to prefer a PATHEXT …
b61a4da
…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 <[email protected]>
@dairiki dairiki mentioned this pull request Nov 1, 2023
Test under python 3.12 lektor/lektor#1167
Merged
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@csm10495 @Glyphack
pythongh-109590: Update shutil.which on Windows to prefer a PATHEXT e…
e8ed9d3
…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.
@serhiy-storchaka serhiy-storchaka mentioned this pull request Nov 22, 2024
shutil.which() can return non-executable path starting with 3.12 on Windows #127001
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2026
feat: measure onboarding postconditions baksohyeon/mogui-ADE-orchestrator#95
Merged
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zooba zooba Awaiting requested review from zooba

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@csm10495 @zooba @miss-islington
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.