Embedding -- getting error/traceback information not to stderr?

Erwin S. Andreasen erw at dde.dk
Mon Jan 24 11:29:47 EST 2000


In my application using embedded Python, I'd like to print out the error
information as it occurrs (traceback, etc.). This is what PyErr_PrintEx()
(called from PyErr_Print()) does -- unfortunately, it does it to sys.stderr.

Did I miss some other similar function that will return the nicely formatted
exception information in a variable?

Otherwise it looks like my options are: 
 1) copy PyErr_Print(), modify it to append to a file (yuck!)
 2) Modify sys.stderr to append to an internal buffer instead of a file

2) seems to be a better option (I'm not certain it's possible).


PS: Where does the filename in the stack trace messages come from? I can't
quite find it in the code: I create my modules with PyImport_AddModule and
setup a restricted environment then parse the code from a file. I've
__file__, but maybe I do it too late.


-- 
==============================================================================
Erwin Andreasen   Herlev, Denmark <erw at dde.dk>          UNIX System Programmer
<URL:http://www.andreasen.org>              <*>              Goodbye, Richard!
==============================================================================



More information about the Python-list mailing list