PyErr_Occurred() and debugging
Mark Hammond
mhammond at skippinet.com.au
Tue Oct 8 08:32:32 EDT 2002
Max wrote:
> Hi!
> I try to debug a python script embedded in a vc++ win32 app.
> I need to catch exceptions and print the error message with the traceback.
>
> if(PyErr_Occurred()){
> PyErr_Print();
> return;
> }
>
> Now, I have two questions...
> How can I redirect the error to the vc debug panel?
It is a PITA from C++ code. I can direct you to c++ which could do it,
but a better way is to get Python itself to do it.
Have your main entry point function do something like:
try:
do_the_real_thing()
except:
file=StringIO.StringIO()
traceback.print_exc(file=file)
win32api.OutputDebugString(file.get_value())
> Is it possible to debug the python script in plain text, like in PythonWin?
> I mean... I have the Update method called by c++ code:
Nope :(
Mark.
More information about the Python-list
mailing list