diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2020-08-08 10:43:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-08 10:43:22 +0200 |
commit | fbe486df459909065d6852a7495a212dfd2accef (patch) | |
tree | fc18bd967cba26741a9c90474361f641201c5205 | |
parent | b39a2a502065ec1407417ffacdac2154385bf80f (diff) | |
parent | 1168d1ff9087e30d88bf18ec405ad0a8cf25f5c7 (diff) | |
download | nextpnr-fbe486df459909065d6852a7495a212dfd2accef.tar.gz nextpnr-fbe486df459909065d6852a7495a212dfd2accef.tar.bz2 nextpnr-fbe486df459909065d6852a7495a212dfd2accef.zip |
Merge pull request #485 from YosysHQ/exception_translation
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; |