Catching Python exceptions from C++ ...

Alex Walsh alexwalsh at
Tue Jul 3 22:50:34 EDT 2001

Hi all!

I have embedded Python in my C++ application and fire off a script by
calling the PyRun_SimpleFileExFlags() function.

The problem is that it only returns a bool to indicate failure. I have
no way of knowing what caused it.

So, I have two questions:
1. How can I extract the exception that caused the script problem from
this function?
2. Can I perhaps set stdin, stdout, stderr to my own FILE handles and at
least dump the output/trace info to something I can read later? If so,

Thanx in advance,

More information about the Python-list mailing list