#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flufl.enum import Enum
from bunch import Bunch
class MyEnum(Enum):
VAL1 = 1
VAL2 = 2
VAL3 = 3
b = Bunch()
b.x = 1
b.e = MyEnum.VAL1
print(b)
It raises
Traceback (most recent call last):
File "bug_bunch_enum.py", line 16, in <module>
print(b)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bunch/__init__.py", line 384, in toYAML
return yaml.safe_dump(self, **opts)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/__init__.py", line 218, in safe_dump
return dump_all([data], stream, Dumper=SafeDumper, **kwds)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/__init__.py", line 190, in dump_all
dumper.represent(data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 28, in represent
node = self.represent_data(data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 57, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bunch/__init__.py", line 342, in to_yaml_safe
return dumper.represent_dict(data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 223, in represent_dict
return self.represent_mapping(u'tag:yaml.org,2002:map', data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 123, in represent_mapping
node_value = self.represent_data(item_value)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 67, in represent_data
node = self.yaml_representers[None](self, data)
File "/Users/scls/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/yaml/representer.py", line 247, in represent_undefined
raise RepresenterError("cannot represent an object: %s" % data)
yaml.representer.RepresenterError: cannot represent an object: MyEnum.VAL1
Hello,
I did this
It raises
Any idea how to fix this ?
Kind regards
Sébastien