Steps to reproduce:
import yaml
import enum
class Spam(enum.Enum):
Value = 1
yaml.dump(Spam)
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. Since enum.Enum has a meta class, the normal dumping for type instances is not run.
Adding a representer for enum.EnumMeta is a simple workaround, but I suppose the problem could also be solved by making
the representer for type a multi representer.
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.Enumhas a meta class, the normal dumping fortypeinstances is not run.Adding a representer for
enum.EnumMetais a simple workaround, but I suppose the problem could also be solved by makingthe representer for
typea multi representer.