Python errors messages in Windows

Alex Martelli aleax at aleax.it
Sun Sep 16 10:25:03 EDT 2001


Vesselin Peev wrote:

> Dear Colleagues,
> 
> Does anyone know about a straightforward way of capturing the Python error
> messages in a Windows application embedding Python? That is, is there are
> version of PyErr_Print not using stdout?

PyErr_Print doesn't use stdout.  Rather, it uses sys.stderr.  Therefore, 
capturing the error messages is indeed straightforward -- just bind 
sys.stderr to your favourite file-like object, e.g. an instance of type 
cStringIO.StringIO, and its contents will be the "capture" you want.


Alex




More information about the Python-list mailing list