Skip to content

Pickling Annotations can fail #193

Description

@cicdw

Now that cloudpickle is including annotations, there are certain typing classes that fail to pickle in versions of python < 3.7 that are now raising errors when included as annotations:

## python 3.6.6importtypingimportcloudpicklett=typing.Union[str, typing.List[str]]
cloudpickle.dumps(tt, protocol=cloudpickle.DEFAULT_PROTOCOL) # always fails# _pickle.PicklingError: Can't pickle typing.Union[str, typing.List[str]]: it's not the same object as typing.Uniondeff(x: tt) ->tt:
returnx## passes in cloudpickle==0.5.3 because type annotations were ignored## but fails in 0.5.4+cloudpickle.dumps(f, protocol=cloudpickle.DEFAULT_PROTOCOL)

All of this works fine in python 3.7

Related: python/typing#511

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