This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients docs@python, eryksun, gaborjbernat, keller00, paul.moore, steve.dower, tim.golden, vinay.sajip, zach.ware
Date 2020-10-18.22:46:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603061165.22.0.657466299753.issue42041@roundup.psfhosted.org>
In-reply-to
Content
> 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
History
Date User Action Args
2020-10-18 22:46:05eryksunsetrecipients: + eryksun, paul.moore, vinay.sajip, tim.golden, docs@python, zach.ware, steve.dower, gaborjbernat, keller00
2020-10-18 22:46:05eryksunsetmessageid: <1603061165.22.0.657466299753.issue42041@roundup.psfhosted.org>
2020-10-18 22:46:05eryksunlinkissue42041 messages
2020-10-18 22:46:05eryksuncreate