On Fri, Nov 11, 2016 at 10:46 AM, Thorsten Kampe <thors...@thorstenkampe.de> wrote: > * eryk sun (Fri, 11 Nov 2016 09:55:23 +0000) >> >> If it works like cmd.exe, then it does its own search using %Path% >> and %PathExt%. For example: >> >> C:\>cmd /c "set "PATH=" & cmd" >> 'cmd' is not recognized as an internal or external command, >> operable program or batch file. >> >> But why should subprocess.Popen implement its own search like the >> shell instead of relying on CreateProcess to search for the >> executable? You'd have to come up with an argument to convince the >> devs to change the behavior in 3.7. > > My goal is to verify that other shells/interpreters on Windows work > the same way as Python when running an application or creating a sub- > process. Cmd does not. What's else there? I have Bash here but that's > a Cygwin executable. And Cygwin Python does not work like Windows > Python. > > Any ideas?
PowerShell uses its own search: C:\>powershell -c "$Env:Path=''; powershell" powershell : The term 'powershell' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:15 + $Env:Path=''; powershell + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (powershell:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException These shells implement their own search because they use %PathExt% to broaden the search and then call ShellExecuteEx to be able to execute/open files that CreateProcess cannot. The only file extension that CreateProcess tries to append is .EXE. Since subprocess.Popen doesn't call ShellExecuteEx, it would make no sense for it to use a custom search that tries appending all of the file extensions in %PathExt%. Thus the only case for Popen to implement its own search is to avoid the implicit directories that CreateProcess searches ahead of %Path%. But implicitly searching the application directory and system directories ahead of %Path% is a feature for Windows applications, and Python is primarily an application development language on Windows -- not a system administration language that takes the place of the shell. -- https://mail.python.org/mailman/listinfo/python-list