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

Fail to (un)pickle class with abc.ABCMeta metaclass (python 2.7) #103

Closed
AmatanHead opened this issue Jul 1, 2017 · 5 comments · Fixed by #104
Closed

Fail to (un)pickle class with abc.ABCMeta metaclass (python 2.7) #103

AmatanHead opened this issue Jul 1, 2017 · 5 comments · Fixed by #104
Labels

Comments

@AmatanHead
Copy link

AmatanHead commented Jul 1, 2017

Hello!

The current code from the master branch fails to work with classes that have the abc.ABCMeta metaclass.

MWE:

class Q(object):
    __metaclass__ = abc.ABCMeta

q = Q()
cloudpickle.loads(cloudpickle.dumps(q))

With python 2.7.3 this yields:

object.__new__(getset_descriptor) is not safe, use getset_descriptor.__new__()

With python 2.7.13:

TypeError: can't pickle wrapper_descriptor objects
@AmatanHead AmatanHead changed the title Fail to unpickle class with abc.ABCMeta metaclass (py2.7) Fail to (un)pickle class with abc.ABCMeta metaclass (python 2.7) Jul 1, 2017
@llllllllll
Copy link
Contributor

This probably broke with #102, ping @ssanderson

@llllllllll llllllllll added the bug label Jul 1, 2017
@ssanderson
Copy link

@llllllllll I think this was broken before #102. I tried rolling back and hit a RecursionError with the following test:

    def test_abc(self):
        class AbstractClass(metaclass=abc.ABCMeta):
            pass

        result = pickle_depickle(AbstractClass())

@ssanderson
Copy link

The root issue here is actually that ABCMeta uses WeakSet for caching. Should be fixed by #104.

@ssanderson
Copy link

ssanderson commented Jul 1, 2017

@AmatanHead I can't reproduce the exact error from your initial post, but ABCMeta instances generally seem to be working on #104 if you want to give it a try.

@AmatanHead
Copy link
Author

Wow! That was blazingly fast and it works! Thanks a lot!

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.

3 participants