I understand that type annotations are not supported for Python 3.6, but I'm getting an AttributeError for abc._get_dump when pickling generic type annotations.
- Python 3.6.8
- cloudpickle 1.3.0:
File "/home/pedro/.virtualenvs/KZG8XYVK/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 899, in save_global
self.save_dynamic_class(obj)
File "/home/pedro/.virtualenvs/KZG8XYVK/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 642, in save_dynamic_class
(registry, _, _, _) = abc._get_dump(obj)
AttributeError: module 'abc' has no attribute '_get_dump'
Here's a minimal example to reproduce the error:
importtypingimportcloudpickleX=typing.TypeVar("X")
classInput(typing.Generic[X]):
passclassLero:
a: Input[int]
obj=Lero()
cloudpickle.dumps(obj)My workaround for it was patching the abc module with a copy of the pure Python implementation of _get_dump at https://github.com/python/cpython/blob/3.7/Lib/test/libregrtest/refleak.py#L8
try:
importabcabc._get_dumpexceptAttributeError:
importweakrefdef_get_dump(cls):
# Reimplement _get_dump() for pure-Python implementation of# the abc module (Lib/_py_abc.py)registry_weakrefs=set(weakref.ref(obj) forobjincls._abc_registry)
return (registry_weakrefs, cls._abc_cache,
cls._abc_negative_cache, cls._abc_negative_cache_version)
abc._get_dump=_get_dump
I understand that type annotations are not supported for Python 3.6, but I'm getting an
AttributeErrorforabc._get_dumpwhen pickling generic type annotations.Here's a minimal example to reproduce the error:
My workaround for it was patching the abc module with a copy of the pure Python implementation of
_get_dumpat https://github.com/python/cpython/blob/3.7/Lib/test/libregrtest/refleak.py#L8