You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: cannot pickle '_abc._abc_data' object when using cloudpickle with ABC derived classes with type annotations on CPython 3.14 #140820
I am not sure if this can be considered a regression or not, but the following cloudpickle code that used to work with CPython 3.13 no longer works with CPython 3.14:
Note that removing the type annotation, e.g. with:
classModel(ABC):
field=0
makes the problem vanish.
Since I have no idea about the internals of _abc._abc_data and how they relate to type annotations, I would appreciate some opinions if this change of behavior of CPython is intended or not and if it is, how we could deal with it in cloudpickle.
changed the title [-]`TypeError: cannot pickle '_abc._abc_data' object` when using cloudpickle on CPython 3.14[/-][+]`TypeError: cannot pickle '_abc._abc_data' object` when using cloudpickle with ABC derived classes with type annotations on CPython 3.14[/+]on Oct 31, 2025
This is going to be for cloudpickle to figure out; I think it comes with their territory of doing advanced introspection and reconstruction of objects.
The annotate function added by PEP-649 / PEP-749 comes with a closure that contains a reference back to the class dict. Presumably to solve this, cloudpickle should detect that the dict in this closure is the same as the class dict, and avoid trying to serialize it again.
Reacted by Olivier Grisel, Serhiy Storchaka and yihong
Thanks for the hint. It is curious that the builtin memoization mechanism of the pickler does not handle that automatically for us, but I guess the devil is in the details. We will investigate on the cloudpickle side. Let me close here.
Activity
[-]`TypeError: cannot pickle '_abc._abc_data' object` when using cloudpickle on CPython 3.14[/-][+]`TypeError: cannot pickle '_abc._abc_data' object` when using cloudpickle with ABC derived classes with type annotations on CPython 3.14[/+]picnixz commentedon Oct 31, 2025
cc @JelleZijlstra
JelleZijlstra commentedon Oct 31, 2025
This is going to be for cloudpickle to figure out; I think it comes with their territory of doing advanced introspection and reconstruction of objects.
The annotate function added by PEP-649 / PEP-749 comes with a closure that contains a reference back to the class dict. Presumably to solve this, cloudpickle should detect that the dict in this closure is the same as the class dict, and avoid trying to serialize it again.
ogrisel commentedon Oct 31, 2025
Thanks for the hint. It is curious that the builtin memoization mechanism of the pickler does not handle that automatically for us, but I guess the devil is in the details. We will investigate on the cloudpickle side. Let me close here.