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
Subclasses of enum.Enum can't be dumped #511
Comments
One way or another, this shouldn't be too hard to fix for pyyaml 6.0... That said- I am curious what you're doing that you're serializing actual types- care to share? Serializing instances of custom enums makes total sense (and works fine), but the tests around serializing language infra are ancient (ie, long-predating |
I was dumping a quick attempt at an ECS, where types were used as keys in a dict. Essentially, a value is saved in a dict with its type as key. |
fixed by #556 |
Steps to reproduce:
gives
TypeError: __reduce_ex__() missing 1 required positional argument: 'proto'
in
represent_object(self, data)
.My analysis:
The dumping code is calling
Spam
's__reduce_ex__
method on the class itself and therefore supplies one argument less than needed. Sinceenum.Enum
has a meta class, the normal dumping fortype
instances is not run.Adding a representer for
enum.EnumMeta
is a simple workaround, but I suppose the problem could also be solved by makingthe representer for
type
a multi representer.The text was updated successfully, but these errors were encountered: