Success with subprocess communicate on Windows?
tjreedy at udel.edu
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
http://bugs.python.org/issue21880 works on linux. The key part of the
new code at http://bugs.python.org/file35819/3rdpartychecker-v2.diff is
+from subprocess import Popen, PIPE
+ proc = Popen(args, stdout=PIPE, stderr=PIPE)
+ output, error = map(lambda b:b.decode('utf-8'),
It does not work on Windows. As I reported on
>>> subprocess.check_output("pyflakes -h")
works in the interpreter and Idle shell, while
>>> s.check_output("pyflakes c:\programs\python34\lib\turtle.py")
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