Skip to content

failed to pickle objects inherited from __slots__ in 1.2.2 #311

@hotpxl

Description

@hotpxl

My first test program is

class Base(object):
    __slots__ = []

class Inherited(Base):
    def __init__(self, v):
        self.v = v

import cloudpickle

a = Inherited(1)
with open("pickle", "wb") as f:
    cloudpickle.dump(a, f)

And then I read the pickle file with

import cloudpickle

with open("pickle", "rb") as f:
    cloudpickle.load(f)

When I run this with Python 3 and cloudpickle 1.2.2, it gives me error

Traceback (most recent call last):
  File "algo/code2.py", line 4, in <module>
    cloudpickle.load(f)
AttributeError: 'Inherited' object has no attribute '__dict__'

But this runs fine under Python 2 and cloudpickle 0.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions