Getting the error in embedded python

Mark Hammond mhammond at
Thu Mar 9 23:10:07 CET 2000

I believe you will find that PyRun_SimpleString() actually detects the
error, and calls PyErr_Print(), which clears the error.  You may not
be seeing the traceback as your app does not have a decent stdout

You have the Python sources - you can confirm this for yourself.

You probably want to use the lower level calls - PyEval_CallObject


"Boris Ottlewski" <Boris.Ottlewski at> wrote in
message news:38c7bc91$0$22621 at
> Hi,
> I just run a simple script with a syntax error:
>   int res = PyRun_SimpleString("import this_module_does_not exist");
>   if (res!=0)
>   {
>        if (PyErr_Occurred())
>       {
>          //never happens
>       }
>    }
> I never get an PyErr_Occured. Also when I do PyErr_Fetch its empty.
> is -1 if I got an error).
> Why is that so? How do I get the error message?
> regards,
> Boris Ottlewski

More information about the Python-list mailing list