IDLE doesn't show stderr output from extension modules

B

Brian Cole

I'm importing an extension module created with SWIG. When working with
the module interactively in IDLE there should be warning and error
messages printed to stderr by the extension module. However, these are
not being caught by the IDLE window, they are going directly to the
terminal that was used to start IDLE.

Strange, because sys.stderr.write() does print to the IDLE window.
I've tried this on Windows and OSX, so it doesn't appear to be a
platform issue. Is this just a fundamental deficiency in the IDLE
shell prompt?

-Brian
 
R

Robert Kern

Brian said:
I'm importing an extension module created with SWIG. When working with
the module interactively in IDLE there should be warning and error
messages printed to stderr by the extension module. However, these are
not being caught by the IDLE window, they are going directly to the
terminal that was used to start IDLE.

Strange, because sys.stderr.write() does print to the IDLE window.
I've tried this on Windows and OSX, so it doesn't appear to be a
platform issue. Is this just a fundamental deficiency in the IDLE
shell prompt?

Yup. IDLE swaps out the sys.stdout and sys.stderr objects at the Python level.
It does not replace the STDOUT and STDERR C file pointers. Python code and C
extension modules which use the Python APIs to write stuff out should get
redirected, but extension modules that use fprintf(), etc., directly to STDOUT
and STDERR won't.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top