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-75586: Fix case where PATHEXT isn't applied to items in PATH (Windows) by csm10495 · Pull Request #103179 · python/cpython

Conversation

@csm10495

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@csm10495
pythonGH-75586 - Fix case where PATHEXT isn't applied to items in PAT…
01c152e
…H (Windows)
@bedevere-bot bedevere-bot added the awaiting review label Apr 2, 2023
@bedevere-bot bedevere-bot mentioned this pull request Apr 2, 2023
shutil.which doesn't find files without PATHEXT extension on Windows #75586
Closed
@arhadthedev arhadthedev added OS-windows stdlib Standard Library Python modules in the Lib/ directory labels Apr 2, 2023
@arhadthedev 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
arhadthedev requested a review from a team April 2, 2023 03:58
eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

csm10495 added 2 commits April 2, 2023 13:06
@csm10495
PR updates
0d4cd7b
@csm10495
Add tests
5fac84a
eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

@csm10495
PR updates
fa145da
@csm10495

csm10495 commented Apr 2, 2023

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

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

csm10495 and others added 4 commits April 2, 2023 15:00
@csm10495
line len fix
84a7976
@blurb-it
📜🤖 Added by blurb_it.
63a06c4
@csm10495
Add changelog entry
7686a23
@csm10495
Double backticks
381e4fe
eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

csm10495 and others added 2 commits April 2, 2023 15:36
@csm10495 @eryksun
Update Lib/shutil.py
e7c0b58
Co-authored-by: Eryk Sun <[email protected]>
@csm10495
PR updates
26e3b15
eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/shutil.py Resolved

Uh oh!

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

@csm10495
pep8 fix
6272b62
eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/test/test_shutil.py Resolved

Uh oh!

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

eryksun
eryksun reviewed Apr 2, 2023
View reviewed changes
Comment thread Lib/test/test_shutil.py Resolved

Uh oh!

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

csm10495 and others added 2 commits April 2, 2023 16:10
@csm10495 @eryksun
Update Lib/test/test_shutil.py
b6d29c8
Co-authored-by: Eryk Sun <[email protected]>
@csm10495 @eryksun
Update Lib/test/test_shutil.py
1096cb7
Co-authored-by: Eryk Sun <[email protected]>
@eryksun eryksun added the 3.12 only security fixes label Apr 2, 2023
@csm10495
csm10495 requested a review from zooba April 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 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@csm10495

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.
All reactions

Sorry, something went wrong.

Uh oh!

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

@csm10495
kick ci
f9267da
eryksun
eryksun reviewed Apr 4, 2023
View reviewed changes
Comment thread Doc/library/shutil.rst Resolved

Uh oh!

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

csm10495 added 2 commits April 4, 2023 13:49
@csm10495
Mention cwd first behavior
d1e68ff
@csm10495
Wording
9badf8c
@csm10495

csm10495 commented Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

@eryksun added. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

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

eryksun
eryksun approved these changes Apr 4, 2023
View reviewed changes

@eryksun eryksun left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM. Thank you, Charles.

Sorry, something went wrong.

Uh oh!

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

csm10495 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Apr 4, 2023
@zooba
zooba merged commit 935aa45 into python:main Apr 4, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Apr 4, 2023
@eryksun eryksun mentioned this pull request Apr 8, 2023
shutil.which wrong result on Windows #68693
Closed
gaogaotiantian pushed a commit to gaogaotiantian/cpython that referenced this pull request Apr 8, 2023
@csm10495 @gaogaotiantian
pythonGH-75586: Make shutil.which() on Windows more consistent with t…
eaaa7b9
…he OS (pythonGH-103179)
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@csm10495 @warsaw
pythonGH-75586: Make shutil.which() on Windows more consistent with t…
60d711f
…he OS (pythonGH-103179)
@dairiki dairiki mentioned this pull request Sep 20, 2023
On Windows, shutil.which incorrectly resolves to non-executable extensionless files (python >= 3.12.0b1) #109590
Closed
@lazka lazka mentioned this pull request Sep 29, 2023
Missing rule for glib-mkenums mesonbuild/meson#12271
Closed
@weiji14 weiji14 mentioned this pull request Oct 25, 2023
Add support for Python 3.12 GenericMappingTools/pygmt#2711
Merged
7 tasks
@popescu-v popescu-v mentioned this pull request Oct 8, 2024
245 support the new version of khiops env KhiopsML/khiops-python#252
Merged
This was referenced Nov 19, 2024
external_project: workaround for MinGW mesonbuild/meson#13886
Merged
shutil.which() can return non-executable path starting with 3.12 on Windows #127001
Closed
@vstinner

vstinner commented Nov 19, 2024

Copy link
Copy Markdown
Member

This change introduced a regression: #127001.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Avasam Avasam mentioned this pull request Mar 4, 2025
shutil.which cannot return PathLike, and fails with cmd: PathLike on Windows Python < 3.12 python/typeshed#13580
Merged
@liaochris liaochris mentioned this pull request Jan 7, 2026
PR for #137: test new python versions JMSLab/Template#138
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jul 30, 2026
fix: make Doctor repairs actionable and resilient cisco-ai-defense/defenseclaw#644
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 19, 2026
feat(console): code structure table with import coupling Lyellr88/marm-memory#150
Merged
@danielhanchen danielhanchen mentioned this pull request Aug 24, 2026
Prefer the .cmd sibling when Windows resolves an extensionless npm shim unslothai/unsloth#9238
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 24, 2026
[Dev Tooling] Consistent dev server port and Node version pin dimagi/open-chat-studio#4268
Merged
1 task
Copilot AI mentioned this pull request Oct 29, 2026
fix(auth): prevent current-directory Azure CLI execution github/spec-kit#5185
Closed
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eryksun eryksun eryksun approved these changes
@zooba zooba Awaiting requested review from zooba

Uh oh!

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

Assignees

No one assigned

Labels

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

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.

6 participants

@csm10495 @eryksun @zooba @vstinner @arhadthedev @bedevere-bot
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.