[C++-sig] problem embedding python - very simple example
Stefan Seefeld
stefan at seefeld.name
Tue Nov 6 20:49:31 CET 2012
On 11/06/2012 02:40 PM, Cory Riddell wrote:
> It prints "hello\nworld\n" then throws an exception executing the line
> that creates the hello.txt file:
> First-chance exception at 0x755ac41f in Test.exe: Microsoft C++
> exception: boost::python::error_already_set at memory location 0x0039fb60..
> Unhandled exception at 0x773915de (ntdll.dll) in Test.exe: Microsoft
> C++ exception: boost::python::error_already_set at memory location
> 0x0039fb60..
>
> In the exec method, the exception is being thrown when result comes back
> as null:
> PyObject* result = PyRun_String(s, Py_file_input, global.ptr(),
> local.ptr());
> if (!result) throw_error_already_set();
I suggest you wrap your C++ code in a try block, then catch the
error_already_set error and inspect the Python exception using
PyErr_Print() or somesuch.
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list