File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -1579,10 +1579,15 @@ def gen_default_impl(self):
15791579 return_stmt = "return " if self .ret_type .name != "void" else ""
15801580
15811581 text += ")\n \t \t {"
1582- text += "\n \t \t \t if (boost::python::override py_" + self .alias + " = this->get_override(\" py_" + self .alias + "\" ))"
1583- text += f"\n \t \t \t \t { return_stmt } " + call_string
1584- text += "\n \t \t \t else"
1582+ text += "\n \t \t \t if (boost::python::override py_" + self .alias + " = this->get_override(\" py_" + self .alias + "\" )) {"
1583+ text += "\n \t \t \t \t try {"
1584+ text += f"\n \t \t \t \t \t { return_stmt } " + call_string
1585+ text += "\n \t \t \t \t } catch (boost::python::error_already_set &) {"
1586+ text += "\n \t \t \t \t \t log_python_exception_as_error();"
1587+ text += "\n \t \t \t \t }"
1588+ text += "\n \t \t \t } else {"
15851589 text += f"\n \t \t \t \t { return_stmt } " + self .member_of .name + "::" + call_string
1590+ text += "\n \t \t \t }"
15861591 text += "\n \t \t }"
15871592
15881593 text += "\n \n \t \t " + self .ret_type .gen_text () + " default_py_" + self .alias + "("
@@ -2335,6 +2340,11 @@ def gen_wrappers(filename, debug_level_ = 0):
23352340
23362341namespace YOSYS_PYTHON {
23372342
2343+ [[noreturn]] static void log_python_exception_as_error() {
2344+ PyErr_Print();
2345+ log_error("Python interpreter encountered an exception.\\ n");
2346+ }
2347+
23382348 struct YosysStatics{};
23392349""" )
23402350
You can’t perform that action at this time.
0 commit comments