Success with subprocess communicate on Windows?

Terry Reedy tjreedy at
Tue Jul 1 23:05:58 CEST 2014

I am mentoring a GSOC student, Saimadhav Heblikar, who is working on 
adding the following feature to Idle: submit the editor text to an 
external program, such as pyflakes, and display the result in an 
OutputWindow. If it reports line numbers with problems, as pyflakes 
does, users will be able to jump to the line in the file (this exists 
already for multiple-file grep output).

The 'obvious' implementation is to use subprocess.Open.communicate to 
run the process and capture the output. The prototype code at works on linux. The key part of the 
new code at is

+from subprocess import Popen, PIPE
+            proc = Popen(args, stdout=PIPE, stderr=PIPE)
+            proc.wait()
+            output, error = map(lambda b:b.decode('utf-8'), 

It does not work on Windows. As I reported on, msg222053,
 >>> subprocess.check_output("pyflakes -h")
works in the interpreter and Idle shell, while
 >>> s.check_output("pyflakes c:\programs\python34\lib\")
gives bizarre output in the interpreter and hangs in the idle shell, as 
does the code above.

My question is whether anyone reading that has had success getting 
subprocess output capture to work consistently on Windows?

Terry Jan Reedy

More information about the Python-list mailing list