Hier ist was ich bisher habe: < /p>
Code: Select all
PyObject* mod = PyImport_ImportModule("myModule");
PyObject* dict = PyModule_GetDict(mod);
// (Some args are initialized before this point, please ignore)
PyObject* mainWindow = PyDict_GetItemString(dict, "MainWindow");
PyObject* myObject = PyObject_Call(mainWindow, args, NULL);
if (!myObject )
{
if (PyErr_Occurred())
{
// Try to get the error as a C string
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
PyErr_NormalizeException(&type, &value, &traceback);
// This should turn 'value' into a python exception object?
PyObject *errStr = PyObject_Str(value);
char *pStrErrorMessage = PyUnicode_AsUTF8(errStr);
std::string errString(pStrErrorMessage);
}
}
Wie bekomme ich die Python -Ausnahme in C/C ++ richtig? (Boost nicht verfügbar)