You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not clear from the documentation how could one expose a C++ exception to Python that needs to have e.g. an additional readonly property. The output of py::register_exception() does not seem to have .def_property_readonly extension.
Problem #2: I wanted to write a custom translator using py::register_exception_translator, but documentation insists of using py::set_error inside, yet this function does not accept additional arguments beside the error message, so I would have no way of passing the custom value that should be exposed via that readonly property.
I'm also coming from #2884, but the workaround suggested there to use Python's exception instantiation would not solve the issue of passing a custom attribute into initializer.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm not clear from the documentation how could one expose a C++ exception to Python that needs to have e.g. an additional readonly property. The output of
py::register_exception()
does not seem to have.def_property_readonly
extension.Problem #2: I wanted to write a custom translator using
py::register_exception_translator
, but documentation insists of usingpy::set_error
inside, yet this function does not accept additional arguments beside the error message, so I would have no way of passing the custom value that should be exposed via that readonly property.I'm also coming from #2884, but the workaround suggested there to use Python's exception instantiation would not solve the issue of passing a custom attribute into initializer.
Is it at all possible in pybind? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions