-
Notifications
You must be signed in to change notification settings - Fork 950
Milestone
Description
PyErr is a very odd structure. It pretends to emulate the 3-tuple returned by PyErr_Fetch, but then its pvalue is a 3-variant that also allows lazy construction of exception objects.
As thus it fails to implement a couple of traits typically expected of the error type (std::error::Error, std::fmt::Display, Sync and Send) and does not integrate very well with the error handling story in Python.
There are a couple of ways to go forward here, but one of the simpler things that could be done I think is:
- Add a method along the lines of
fn(Python, PyErr) -> Py<BaseException>;- I don’t believe this can be done easily right now without unsafe code.
- Implement the typical error traits for
Py<ExceptionT>types.- Specifically for
Displayand friends I think it is fine to just do aPython::acquire_gil()inside if that is necessary to format the data.
- Specifically for
Willing to contribute the necessary code to implement this. Please let me know what you think about this. Perhaps other approaches seem better?
Reactions are currently unavailable