Re: Python Embedding: redirecting output

Hammond, Mark (MHammond@jm.cmutual.com.au)
Fri, 10 Feb 95 12:27:00 PST

> Changing sys.stderr and sys.stdout works well with all Python
> generated output. But the interpreter itself can produce error
> messages on stderr that you might want to catch. These messages
> are internal error messages and will not occur under normal conditions.
>
> To catch the internal messages I redirected stderr to a file
> so I know I will get the message in case anything appears.

This is getting better with each Python release. AFAIK, there are only
about 3 or 4 places in the code that do the fprintf(stderr,...) thing -
usually followed by an abort().

Even this code seems to be moving towards a generic abort function (cant
remember the name) so an application should be able to override the abort
function at link time.

In my expericene imbedding Python, I have only seen such errors very few
times - stuffing reference counts is a pretty good way to get them. I have
never seen such an error message from bad Python code - just bad C code
wrapped around Python.

Basically I am saying that explicitely grabbing stderr is a good idea, but
probably not worth it for the number of times anything will be written to
it.

Mark.