aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-07-05 11:57:41 +0200
committerGitHub <noreply@github.com>2019-07-05 11:57:41 +0200
commit030483ffb909ab38e10d437d09ec922cb0ad2ce8 (patch)
treeff0b3a426037d29970b1a88a98e0d5ce8f0b5306
parentde263281308c112891ef330536bd228460a0f85f (diff)
parent3a1a41bdb16c9cdf587147f8fb9dc910bcddfd26 (diff)
downloadyosys-030483ffb909ab38e10d437d09ec922cb0ad2ce8.tar.gz
yosys-030483ffb909ab38e10d437d09ec922cb0ad2ce8.tar.bz2
yosys-030483ffb909ab38e10d437d09ec922cb0ad2ce8.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;"