Eryk Sun <eryk...@gmail.com> added the comment:

The existing behavior of find_executable() is unusual compared to a native 
Windows file search via CreateProcessW or SearchPathW, for which a default 
".exe" extension is appended only if the executable name doesn't already have 
an extension. (CreateProcessW supports searching for a file that has no 
extension by adding a trailing dot to the name, which in Windows is equivalent 
to the name without the trailing dot.) 

However, I don't think it's prudent to change the default behavior of this old 
code, especially since there are plans to deprecate distutils per PEP 632. It's 
recommended to migrate existing code to use shutil.which() and 
subprocess.run(). 

There are open issues to improve the behavior of shutil.which() in Windows. For 
example, currently it's limited to PATHEXT extensions, which is a 
generalization of how find_executable() works with ".exe". shutil.which() won't 
find "rst2man.py" if ".PY" isn't in PATHEXT. The proper behavior, if the CMD 
shell is the standard of correctness, is to include the exact name as the first 
candidate to check before trying the name plus the PATHEXT extensions. To be 
more like the CMD shell, a name without an extension should be excluded, but 
effectively included anyway if PATHEXT contains a "." entry.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41965>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to