Success with subprocess communicate on Windows?

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Wed Jul 2 13:31:44 EDT 2014


On 02.07.2014 11:05, Terry Reedy wrote:
> On 7/2/2014 12:33 AM, Tim Roberts wrote:
>> Terry Reedy <tjreedy at udel.edu> wrote:
>>
>> You need to use
>>      s.check_output("pyflakes c:\\programs\\python34\\lib\\turtle.py")
>> or
>>      s.check_output(r"pyflakes c:\programs\python34\lib\turtle.py")
>
> Now I get "Command 'pyflakes c:\programs\python34\lib\turtle.py' returns
> non-zero exit status 1" on both. On Idle, as least, a command-prompt
> window is flashed/displayed. It makes no sense to me that in the command
> interpreter,
> 'pyflakes c:\\programs\\python34\\lib' works and
> 'pyflakes c:\\programs\\python34\\lib\\turtle.py' returns status 1.
> whereas both (with quotes elided and undoubled \) work at the command
> prompt.
>

I am not 100% sure whether that is the problem, but from what I gather 
from the subprocess module docs the args string is passed to the Windows 
CreateProcess function as a single string.
To me this seems to imply that it is passed as the lpCommandLine 
parameter (with Null for the lpApplicationName parameter).
This is what Microsoft says about this case 
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx):

<quote>
If lpApplicationName is NULL, the first white space–delimited token of 
the command line specifies the module name. If you are using a long file 
name that contains a space, use quoted strings to indicate where the 
file name ends and the arguments begin (see the explanation for the 
lpApplicationName parameter). If the file name does not contain an 
extension, .exe is appended. Therefore, if the file name extension is 
.com, this parameter must include the .com extension. If the file name 
ends in a period (.) with no extension, or if the file name contains a 
path, .exe is not appended. If the file name does not contain a 
directory path, the system searches for the executable file in the 
following sequence.
</quote>

So in your case the default behavior would be to add an .exe extension 
to pyflakes, which is probably not what you intended ?

Best,
Wolfgang




More information about the Python-list mailing list