Q: stderr redirect - popen2.popen3 - PythonWin crashes

Johannes Eble skywalkerpackage at hotmail.com
Tue Jan 15 11:37:43 EST 2002


Hello all,

I want to use ActivePython 2.1 as a launcher for elj-win32 (an Eiffel
compiler running in the dos box). The compiler is invoked by the
command 'compile'.

This compiler writes the output of the command 'compile -version' (the
version info) to stdout, but it writes the status messages of all real
compiling commands to stderr.

I have used the following code:

import popen2

childStdout, childStdin, childStderr = popen2.popen3('compile
-version')

print childStdout.read()

print childStderr.read()

This works, that is, I get the Stdout version information.

But when I change the 'compile -version' into 'compile main' (compile
the module 'main') to cature the Stderr status messages, PythonWin
doesn't respond anymore after the ~.read() commands. In fact it seems
that the whole PythonWin hangs, I can only kill it through the task
bar.

I have to say that the 'compile' command doesn't just invoke the
Eiffel compiler. 'compile' is a launcher for 'compile_to_c' (the
Eiffel code is first compiled to C) than a C compiler called lccwin32
is invoked and so on.

As you can execute any dos command in Python (with os), it is also
possible to write os.system('compile -version >out.txt'). But I don't
know the dos syntax for redirection of stderr.

It would be great if anybody could help me with the problem.

ByeBye

Johannes



More information about the Python-list mailing list