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
Pickle support was already discussed in #100, customizing __setstate__, __getstate__ and __getnewargs_ex__ works well for customized pyclass.
Unfortunately, when we want to create customized exception using create_exception, it's hard to implement such methods. It seems that the arguments are stored in PyErr instead of the class itself, how can we implement these magic methods ourselves?
I would say the goal is to make exceptions work exactly like your snippet. Create a custom pyclass and inherit from an exception type. That way it's easy to add custom fields, methods and protocols. I think the missing pieces are an easier way to convert these classes into a PyErr, so that they can be raised to Python and a way to make that work on abi3 (potentially #4678 can help with that)
Pickle support was already discussed in #100, customizing
__setstate__
,__getstate__
and__getnewargs_ex__
works well for customized pyclass.Unfortunately, when we want to create customized exception using
create_exception
, it's hard to implement such methods. It seems that the arguments are stored inPyErr
instead of the class itself, how can we implement these magic methods ourselves?Of course, it's better for pyo3 to support these methods directly on
PyErr
. I'd like to help if there is a consensus to do that.The text was updated successfully, but these errors were encountered: