MCPcopy Create free account
hub / github.com/Cantera/cantera / getPythonExceptionInfo

Function getPythonExceptionInfo

src/extensions/PythonExtensionManager.cpp:20–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace {
19
20std::string getPythonExceptionInfo()
21{
22 if (!PyErr_Occurred()) {
23 return "no Python exception raised";
24 }
25
26 PyObject* ex_type;
27 PyObject* ex_value;
28 PyObject* traceback;
29 PyErr_Fetch(&ex_type, &ex_value, &traceback);
30 PyErr_NormalizeException(&ex_type, &ex_value, &traceback);
31 if (traceback == nullptr) {
32 traceback = Py_None;
33 }
34 char* c_exstr = ct_getExceptionString(ex_type, ex_value, traceback);
35 string message;
36 if (c_exstr != nullptr) {
37 message = c_exstr;
38 free(c_exstr);
39 } else {
40 message = "Couldn't get exception message";
41 }
42 Py_XDECREF(ex_type);
43 Py_XDECREF(ex_value);
44 Py_XDECREF(traceback);
45 return message;
46}
47
48} // end anonymous namespace
49

Callers 3

registerRateBuildersMethod · 0.85
registerRateBuilderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected