GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — gh-127001: Fix PATHEXT issues in shutil.which() on Windows by serhiy-storchaka · Pull Request #127035 · python/cpython Conversation
|
|
Ah, nice. I approve of this logic. I have a vague feeling it was discussed at some point, but I think it makes sense to require an extension from |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'll rewrite tests tomorrow. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Some of existing tests did not make sense because they are grounded on wrong model. I replaced them. Also I refactored other tests to make them more uniform and reuse the same files and directories. Fixed also cases when PATHEXT contains a multicomponent extension (e.g. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One comment I'd like to see added, but otherwise looks good
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| pathext_source = os.getenv("PATHEXT") or _WIN_DEFAULT_PATHEXT | ||
| pathext = [ext for ext in pathext_source.split(os.pathsep) if ext] | ||
| pathext = pathext_source.split(os.pathsep) | ||
| pathext = [ext.rstrip('.') and ext for ext in pathext if ext] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I really dislike using and for value selection. I trust that you've got it right here, but I can't read it easily. Can we maybe comment?
# Replace ext of '.' with empty string, but keep trailing dots on '.ext.'
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think that it is better to remove dots in all cases. The behavior of cmd.exe if PATHEXT contains .BAT. and there is a.bat in the path:
a -- hangsa.bat -- founda. -- not founda.bat. -- not foundwhich() will now return the same result, except for the first case. I think this is the best option for now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…honGH-127035) * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo."). (cherry picked from commit 8899e85) Co-authored-by: Serhiy Storchaka <[email protected]>
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-127156 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ws (pythonGH-127035) * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo."). (cherry picked from commit 8899e85) Co-authored-by: Serhiy Storchaka <[email protected]>
|
GH-127158 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-127035) (GH-127156) * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo."). (cherry picked from commit 8899e85) Co-authored-by: Serhiy Storchaka <[email protected]>
…-127035) (GH-127158) * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo."). (cherry picked from commit 8899e85)
…Windows (#2408) This PR aims to address a behavior change in shutil.which (in Windows) introduced in python/cpython#127035. For more context, in test_run_model_exe_rel_path, the mf6 executable is copied to a relative path, ../bin/mf6 (without extension). Within the test, shutil.which is used to locate the executable path. However, with the new changes in shutil.which, by default, it would only search for the path with an extension in PATHEXT, excluding paths without extension.
…honGH-127035) * Name without a PATHEXT extension is only searched if the mode does not include X_OK. * Support multi-component PATHEXT extensions (e.g. ".foo.bar"). * Support files without extensions in PATHEXT contains dot-only extension (".", "..", etc). * Support PATHEXT extensions that end with a dot (e.g. ".foo.").
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.