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
The premise is that I'm in an exception, and __aexit__ is currently being called with that exception. My __aexit__ can potentially encounter another error (asynchronously), so I will have to report that via set_exception on the future.
(The from exc_val here is explicit - but it would have the same effect implicitly as well!)
In pybind11 I do have raise_from - but unlike the native Python code, I'm interfacing with the future object directly in an async context so I can't immediately raise the exception. Instead I have to construct the exception from value, and pass it by value into the future.
Am I missing something obvious, or does pybind11 lack any C++ interface for the task of construction an exception by value instead of directly raising it?
And while at it - what about translating native C++ exceptions to Python exceptions by value via the registered exception translators?
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The premise is that I'm in an exception, and
__aexit__is currently being called with that exception. My__aexit__can potentially encounter another error (asynchronously), so I will have to report that viaset_exceptionon the future.In native Python, I could just do:
(The
from exc_valhere is explicit - but it would have the same effect implicitly as well!)In
pybind11I do haveraise_from- but unlike the native Python code, I'm interfacing with the future object directly in an async context so I can't immediately raise the exception. Instead I have to construct the exception from value, and pass it by value into the future.Am I missing something obvious, or does
pybind11lack any C++ interface for the task of construction an exception by value instead of directly raising it?And while at it - what about translating native C++ exceptions to Python exceptions by value via the registered exception translators?
Beta Was this translation helpful? Give feedback.
All reactions