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 Malcolm Smith, eryksun, iritkatriel, lys.nikolaou, pitrou, serhiy.storchaka, xnovakj, xtreak
Date 2022-01-03.10:35:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641206146.14.0.457237594758.issue34931@roundup.psfhosted.org>
In-reply-to
Content
> On Windows the extension of "python.exe" is "exe", not ".exe". 

FWIW, a file extension in Windows includes the dot. Trailing dots are stripped from filenames, so a file can't be named "python." because it's the same as just "python". (It's possible to prevent stripping trailing dots from a name by using a \\?\ literal path, but creating such a filename is a bad idea.) 

The shell API's file associations include the dot in the file extension. Also, the PATHEXT environment variable (i.e. the list of extensions that a CLI shell should try appending in a PATH search) includes the dot in each extension. In both of the latter cases, an extension that's just "." matches a filename that has no extension. In other words, the "." file extension can be used to associate files that have no extension with a ProgID (i.e. a programmatic identifier, which defines properties and actions for a file type), and adding "." to PATHEXT includes files that have no extension in a PATH search.

To clarify further, here are some results from PathCchFindExtension() [1]:

    import ctypes
    path = ctypes.OleDLL('api-ms-win-core-path-l1-1-0')
    s = (ctypes.c_wchar * 100)()
    ext = ctypes.c_wchar_p()

    >>> s.value = 'python.exe'
    >>> _ = path.PathCchFindExtension(s, len(s), ctypes.byref(ext))
    >>> ext.value
    '.exe'

    >>> s.value = '...exe'
    >>> _ = path.PathCchFindExtension(s, len(s), ctypes.byref(ext))
    >>> ext.value
    '.exe'

    >>> s.value = 'python.'
    >>> _ = path.PathCchFindExtension(s, len(s), ctypes.byref(ext))
    >>> ext.value
    '.'

---
[1] https://docs.microsoft.com/en-us/windows/win32/api/pathcch/nf-pathcch-pathcchfindextension
History
Date User Action Args
2022-01-03 10:35:46eryksunsetrecipients: + eryksun, pitrou, xnovakj, serhiy.storchaka, Malcolm Smith, lys.nikolaou, xtreak, iritkatriel
2022-01-03 10:35:46eryksunsetmessageid: <1641206146.14.0.457237594758.issue34931@roundup.psfhosted.org>
2022-01-03 10:35:46eryksunlinkissue34931 messages
2022-01-03 10:35:45eryksuncreate