Skip to content

Pickling enum types with cloudpickle #244

Description

@pcmoritz

Dear all,

cloudpickle currently doesn't support pickling types of type enum.EnumMeta. Here is an example to reproduce (on the latest release cloudpickle 0.7):

importcloudpicklefromenumimportIntEnumclassColor(IntEnum):
RED=1u=cloudpickle.dumps(Color)
cloudpickle.loads(u)

gives the error

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-ff791d51315b> in <module>
6 7 u = cloudpickle.dumps(Color)
----> 8 cloudpickle.loads(u)
~/anaconda3/lib/python3.7/enum.py in __new__(metacls, cls, bases, classdict)
149 # save enum items into separate mapping so they don't get baked into
150 # the new class
--> 151 enum_members = {k: classdict[k] for k in classdict._member_names}
152 for name in classdict._member_names:
153 del classdict[name]
AttributeError: 'dict' object has no attribute '_member_names'

Any help with this is appreciated!

-- Philipp.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions