Skip to content
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

Bunch can't be displayed when flufl.enum is used #15

Open
s-celles opened this issue Nov 1, 2014 · 1 comment
Open

Bunch can't be displayed when flufl.enum is used #15

s-celles opened this issue Nov 1, 2014 · 1 comment

Comments

@s-celles
Copy link

s-celles commented Nov 1, 2014

Hello,

I did this

#!/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

Any idea how to fix this ?

Kind regards

Sébastien

@s-celles
Copy link
Author

s-celles commented Nov 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant