Author eryksun
Recipients eryksun, paul.moore, rmccampbell7, serhiy.storchaka, steve.dower, tim.golden, xtreak, zach.ware
Date 2018-09-26.22:18:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In a patch review [1] for issue 24505, I had a discussion with Toby Tobkin about extending the behavior of shutil.which() on Windows. This was to match the behavior of the CMD shell, including securing the search path via NeedCurrentDirectoryForExePath, searching for the exact filename, and implementing a real execute-access check. 

CMD won't directly execute a file that lacks execute access -- even a script or data file. We can implement this with a real implementation of os.access() that checks file security, for which there's an existing issue. (My previous suggestion to use CreateProcess and AssocQueryString to check for execute access was over the top. At the time I was thinking about building out support for a high-level shutil.execute, but it's out of scope here.)

Note that CMD will only try to execute an extensionless file if "." is in PATHEXT. (In the Windows file namespace, "name" and "name." are equivalent.) This obviously works for PE binaries, but we can also define an association for "." in the registy, which is useful for extensionless script files. Just associate "." files with a launcher that tries CreateProcess and falls back on a shebang line.

Date User Action Args
2018-09-26 22:18:08eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, serhiy.storchaka, steve.dower, rmccampbell7, xtreak
2018-09-26 22:18:08eryksunsetmessageid: <>
2018-09-26 22:18:08eryksunlinkissue31405 messages
2018-09-26 22:18:08eryksuncreate