Skip to content

Failed to loads a dumped MetaClass object #302

Description

@yitso

Hello, I met a problem when i call cloudpickle.loads.

This is my code:

importcloudpicklefromscrapy.itemimportItem, FieldMyItem=type('MyItem', (Item,), dict({'id': Field()}))
item=MyItem()
print(cloudpickle.loads(cloudpickle.dumps(item))) # {}print(isinstance(dict().values(), MyItem)) # Falseprint(cloudpickle.loads(cloudpickle.dumps(item))) # raise 

I guess the cache of MetaClass cause to this problem.

isinstance call __instancecheck__ of ABCMeta and finally call __subclasscheck__ of ABCMeta.
code: https://github.com/python/cpython/blob/3.5/Lib/abc.py#L210

And cloudpickle.dumps will dumps the _abc_cache and _abc_negative_cache which has some invalid object, so when I call cloudpickle.loads in second , it raise exception.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions