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

PicklingError with custom classes after cloudpickle #239

Closed
PeterMinin opened this issue Aug 31, 2017 · 0 comments · Fixed by #443
Closed

PicklingError with custom classes after cloudpickle #239

PeterMinin opened this issue Aug 31, 2017 · 0 comments · Fixed by #443
Labels
Milestone

Comments

@PeterMinin
Copy link

I am getting an error trying to serialize objects of a certain custom class that where previously serialized and de-serialized by cloudpickle (in practice, they are created by dask workers). Here is an example, with some comments below.

import cloudpickle


class A(object):
    pass


class B(A):
    def foo(self):
        super()


NewB = cloudpickle.loads(cloudpickle.dumps(B))
b = NewB()

import dill
dill.dumps(b)

This produces an error:
_pickle.PicklingError: Can't pickle <class '__main__.B'>: it's not the same object as __main__.B
Full stack trace: gist.

The error does not happen in either of the following cases:

  • the classes are imported from a module;
  • class B doesn't use super(), i.e. if it's defined like this:
class B(A):
    def foo(self):
        A()
        B()

Versions:
python - 3.5.2
cloudpickle - 0.4.0
dill - 0.2.7.1

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

Successfully merging a pull request may close this issue.

2 participants