-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyosys: catch boost::python::error_already_set #4699
base: main
Are you sure you want to change the base?
Conversation
I think we should catch it here instead: yosys/misc/py_wrap_generator.py Line 1573 in b2d7858
For two reasons:
|
To illustrate it a little better, the generated code looks like
and |
Ahh sure, the main reason I hadn't done that was because I didn't want to get too into the mess of |
* This catches exceptions from internal passes, printing them in a readable manner where the user would otherwise see an unspecified boost exception
f7c2b42
to
8d9a18e
Compare
Have moved it into the generator. The generated c++ diff looks as follows with the other 43a44,48
> [[noreturn]] static void log_python_exception_as_error() {
> PyErr_Print();
> log_error("Python interpreter encountered an exception.\n");
> }
>
447,449c452,458
< if (boost::python::override py_help = this->get_override("py_help"))
< py_help();
< else
---
> if (boost::python::override py_help = this->get_override("py_help")) {
> try {
> py_help();
> } catch (boost::python::error_already_set &) {
> log_python_exception_as_error();
> }
> } else {
450a460
> } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise looks good to me
This catches exceptions from internal passes, printing them in a readable manner where the user would otherwise see an unspecified boost exception.
e.g. consider the following pass in
pass.py
:Previously, when invoked with
yosys -m pass.py -p "help my_pass"
, yosys would error withbut with this change it instead shows