Eryk Sun <eryk...@gmail.com> added the comment:
> For platform semantics, I'd prefer a link to the CreateProcessW docs, > with advice to read about the lpApplicationName parameter with > respect to `executable` and lpCommandLine with respect to `args` > and the platform search semantics. For example, let's help someone figure out that because "python3.8" has a ".8" filename 'extension', ".exe" may or may not be appended in a search. >>> print(shutil.which('python3.8')) C:\Users\someone\AppData\Local\Microsoft\WindowsApps\python3.8.EXE >>> subprocess.call(['python3.8.exe', '-V']) Python 3.8.6 0 SearchPathW (called internally by CreateProcessW) won't append the ".exe" default extension to a name that already has a ".8" extension: >>> try: subprocess.call(['python3.8', '-V']) ... except OSError as e: print(e) ... [WinError 2] The system cannot find the file specified But with shell=True it works because CMD always appends the PATHEXT extensions (thankfully there isn't a "python3.8.com" file to get in the way, since .COM is usually listed before .EXE in PATHEXT): >>> subprocess.call('python3.8 -V', shell=True) Python 3.8.6 0 SearchPathW does append the default ".exe" extension for a qualified path: >>> subprocess.call([r'C:\Users\someone\AppData\Local\Microsoft\WindowsApps\python3.8', '-V']) Python 3.8.6 0 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42041> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com