diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2020-08-07 09:46:02 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2020-08-07 09:46:02 +0200 |
commit | 1168d1ff9087e30d88bf18ec405ad0a8cf25f5c7 (patch) | |
tree | fc18bd967cba26741a9c90474361f641201c5205 | |
parent | b39a2a502065ec1407417ffacdac2154385bf80f (diff) | |
download | nextpnr-1168d1ff9087e30d88bf18ec405ad0a8cf25f5c7.tar.gz nextpnr-1168d1ff9087e30d88bf18ec405ad0a8cf25f5c7.tar.bz2 nextpnr-1168d1ff9087e30d88bf18ec405ad0a8cf25f5c7.zip |
Made proper exception translation
-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; |