aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-04 12:23:35 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-04 14:55:24 +0200
commitf8ad2b31a9a1a43ac415e8b203851c6f091dde6f (patch)
treeb19321a42abf40a3da7ba1c3f4022f6b655605d9 /common
parent3e8bdb5cbdc50a38ca12fa4509261da5080209a1 (diff)
downloadnextpnr-f8ad2b31a9a1a43ac415e8b203851c6f091dde6f.tar.gz
nextpnr-f8ad2b31a9a1a43ac415e8b203851c6f091dde6f.tar.bz2
nextpnr-f8ad2b31a9a1a43ac415e8b203851c6f091dde6f.zip
python: Translate NPNR_ASSERTs to Python
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/pybindings.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc
index e776e33a..ea57dbbb 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -61,8 +61,15 @@ Context *load_design_shim(std::string filename, ArchArgs args)
return d;
}
+void translate_assertfail(const assertion_failure &e) {
+ // Use the Python 'C' API to set up an exception object
+ PyErr_SetString(PyExc_AssertionError, e.what());
+}
+
BOOST_PYTHON_MODULE(MODULE_NAME)
{
+ register_exception_translator<assertion_failure>(&translate_assertfail);
+
using namespace PythonConversion;
class_<GraphicElement>("GraphicElement")