aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-07-05 11:57:41 +0200
committerDavid Shah <dave@ds0.me>2019-07-09 18:48:23 +0100
commit17e0cc010c12fc69fdadc2c342da1ef8e16a2d91 (patch)
tree9d1e6ce83f32a185a45f47767ea8623f3a5daf09
parentfecd3aa2b15a20fc72d790b2437ee016ae879c14 (diff)
downloadyosys-17e0cc010c12fc69fdadc2c342da1ef8e16a2d91.tar.gz
yosys-17e0cc010c12fc69fdadc2c342da1ef8e16a2d91.tar.bz2
yosys-17e0cc010c12fc69fdadc2c342da1ef8e16a2d91.zip
Merge pull request #1159 from btut/fix/1090_segfault_cell_and_wire
Throw runtime exception when trying to convert inexistend C++ object to Python
-rw-r--r--misc/py_wrap_generator.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/misc/py_wrap_generator.py b/misc/py_wrap_generator.py
index 9e5727499..66d661fa1 100644
--- a/misc/py_wrap_generator.py
+++ b/misc/py_wrap_generator.py
@@ -779,6 +779,9 @@ class WClass:
#if self.link_type != link_types.pointer:
text += "\n\t\tstatic " + self.name + "* get_py_obj(" + long_name + "* ref)\n\t\t{"
+ text += "\n\t\t\tif(ref == nullptr){"
+ text += "\n\t\t\t\tthrow std::runtime_error(\"" + self.name + " does not exist.\");"
+ text += "\n\t\t\t}"
text += "\n\t\t\t" + self.name + "* ret = (" + self.name + "*)malloc(sizeof(" + self.name + "));"
if self.link_type == link_types.pointer:
text += "\n\t\t\tret->ref_obj = ref;"