diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/pybindings.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc index b6d5e48a..8f824f1e 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -86,7 +86,13 @@ template <> struct string_converter<Property> PYBIND11_MODULE(MODULE_NAME, m) { - py::register_exception<assertion_failure>(m, "PyExc_AssertionError"); + py::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const assertion_failure &e) { + PyErr_SetString(PyExc_AssertionError, e.what()); + } + }); using namespace PythonConversion; |