[C++-sig] Displaying PyErr_Print() error
paul at paulgrenyer.co.uk
Thu Nov 27 13:07:11 CET 2003
I originally asked this question some weeks ago, but didn't receive a
reply. I've seen from googling that other people have had this problem,
but I haven't seen a solution yet.
I've intergrated boost.python into a COM object and therefore there is
no std::cerr console to display the error message generated by
PyErr_Print() after an exception is thrown.
I've tried redirecting std::cerr to a stream:
catch( const error_already_set& )
std::streambuf* streamBuffer = std::cerr.rdbuf( str.rdbuf() );
std::cerr << python << std::endl;
std::cerr.rdbuf( streamBuffer );
throw BadPython( str.str(), __FILE__, __LINE__ );
The contents of "python", a string holding the python code that
generated the exception, is correctly send to "str", but the exception
Am I doing something wrong? Is there another way to get the error
generated by PyErr_Print() in a string?
Please note the change of email address!
Email: paul at paulgrenyer.co.uk
More information about the Cplusplus-sig