MCPcopy Create free account
hub / github.com/boostorg/cobalt / translate_current_exception

Function translate_current_exception

example/python.cpp:99–112  ·  view source on GitHub ↗

helper function so we can capture the currently active C++ exception into a python object.

Source from the content-addressed store, hash-verified

97
98// helper function so we can capture the currently active C++ exception into a python object.
99py::object translate_current_exception()
100{
101 py::object locals = py::dict();
102 locals["rethrow_"] = py::cpp_function([]{throw;});
103 PyRun_String(R"(
104try:
105 rethrow_();
106 result = None
107except Exception as e:
108 result = e;
109
110)", Py_single_input, PyEval_GetGlobals(), locals.ptr());
111 return locals["result"];
112}
113
114struct py_coroutine
115{

Callers 1

unhandled_exceptionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected