Merge pull request #1159 from btut/fix/1090_segfault_cell_and_wire
authorClifford Wolf <clifford@clifford.at>
Fri, 5 Jul 2019 09:57:41 +0000 (11:57 +0200)
committerDavid Shah <dave@ds0.me>
Tue, 9 Jul 2019 17:48:23 +0000 (18:48 +0100)
Throw runtime exception when trying to convert inexistend C++ object to Python

misc/py_wrap_generator.py

index 9e57274992e561d463b8146bf9005e9fe357546b..66d661fa1ee50cee307c49778ec7c81f6bce4170 100644 (file)
@@ -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;"