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 with python 3.14 and cloudpickle 3.1.2 #585
TypeError: cannot pickle '_abc._abc_data' object
when serializing dict item '_abc_impl'
when serializing tuple item 0
when serializing cell reconstructor arguments
when serializing cell object
when serializing tuple item 0
when serializing dict item '__closure__'
when serializing tuple item 1
when serializing function state
when serializing function object
when serializing dict item '__annotate__'
when serializing skore._utils._parallel._FuncWrapper state
when serializing skore._utils._parallel._FuncWrapper object
changed the title [-]Python==3.14 / cloudpickle==3.1.2 : unable to pickle `TypeError: cannot pickle '_abc._abc_data' object`[/-][+]Python==3.14 / cloudpickle==3.1.2 : unable to pickle[/+]on Dec 16, 2025
Thanks I can reproduce with skore, my guess is that this is a variation of #572 indeed. Compare to #572 the function mentioned in the error message is __annotate__ rather than __annotate_func__, not sure what to make of this right now.
I had a closer look, you can reproduce with a simpler _FuncWrapper:
fromfunctoolsimportupdate_wrapperclass_FuncWrapper:
def__init__(self, function):
self.function=function# you need the following line with update_wrapper to trigger the issueupdate_wrapper(self, self.function)
I am guessing the issue is a combination of the _FuncWrapper + report.metrics.summarize side (without _FuncWrapperreport.metrics.summarize works fine, trying _FuncWrapper with a simple function with type annotations doesn't reproduce the issue).
Looking at the skore code it seems to mix descriptors + advanced typing, so the key for a reproducer without skore lies in understanding what combinations of advanced functionalities create the issue. I tried a few things but could not find the exact combination ...
changed the title [-]python==3.14/cloudpickle==3.1.2: unable to pickle[/-][+]`TypeError: cannot pickle '_abc._abc_data' object` with python 3.14 and cloudpickle 3.1.2[/+]on Dec 22, 2025
Thanks for the skore-based reproducer and the initial investigation. However, I wonder if the cause of the problem comes from cloudpickle itself: I don't see any dynamic class or function in the reproducer, so I don't see why cloudpickle-specific features would be needed for that case.
Indeed, I can reproduce a similar problem with the dumps function of the pickle module of CPython 3.14:
The first call to dumps works fine but the second fails. So I suspect that the wrapper needs to do something special to be picklable to deal with annotated callables on Python 3.14.
Still I think it's worth investigating what's needed to restore regular picklability for the minimal reproducer with CPython 3.14 before debugging cloudpickle specific things on the more complex setting. Maybe solving the simple case will also solve the complex case.
TypeError: cannot pickle '_abc._abc_data' object
when serializing dict item '_abc_impl'
when serializing tuple item 0
when serializing cell reconstructor arguments
when serializing cell object
when serializing tuple item 0
when serializing dict item '__closure__'
when serializing tuple item 1
when serializing function state
when serializing function object
when serializing dict item '__annotate__'
when serializing FuncWrapper state
when serializing FuncWrapper object
Thanks @BioGeek. Before proceeding with the review, I am pondering whether this can still be considered by a regression in CPython or not. If so we should try to report a minimal reproducer upstream and maybe consider #594 as a temporary workaround rather than a definitive fix.
After taking a deeper look, I don't think that the problem that remains can be considered's a regression in CPython but I am not sure what's the cleanest way to deal with it either.
@ogrisel could you please consider merging this temporary fix PR? It would enable us to dump scikit-fingerprints to support Python 3.14, as we depend on cloudpickle. Python 3.15 will be released soon, and being 2 versions behind starts to become inconvenient.
@ogrisel I opened #603 as an alternative fix for this issue.
Part of this is already fixed upstream. The root cause is CPython gh-137814. Fixed in 3.14.5 by gh-148221 and on main by gh-137842. On 3.14.5+ the module-level reproducer of this issue already works with cloudpickle master. @j-adamczyk that may well unblock scikit-fingerprints today, without waiting for a cloudpickle release. What still fails on every 3.14+ build is the case where the annotated class itself is pickled by value (defined in __main__, in a notebook, or otherwise dynamic).
Test suite is green on 3.12, 3.14.4, 3.14.6 and 3.15.0b3
Activity
thomass-dev commentedon Dec 16, 2025
I'm trying to reduce the reproducer, to be used without
skore.[-]Python==3.14 / cloudpickle==3.1.2 : unable to pickle `TypeError: cannot pickle '_abc._abc_data' object`[/-][+]Python==3.14 / cloudpickle==3.1.2 : unable to pickle[/+][-]Python==3.14 / cloudpickle==3.1.2 : unable to pickle[/-][+]Python==3.14 / cloudpickle==3.1.2: unable to pickle[/+][-]Python==3.14 / cloudpickle==3.1.2: unable to pickle[/-][+]python==3.14/cloudpickle==3.1.2: unable to pickle[/+]lesteve commentedon Dec 16, 2025
Thanks I can reproduce with skore, my guess is that this is a variation of #572 indeed. Compare to #572 the function mentioned in the error message is
__annotate__rather than__annotate_func__, not sure what to make of this right now.#578 may have some relevant information as well.
lesteve commentedon Dec 16, 2025
I had a closer look, you can reproduce with a simpler
_FuncWrapper:I am guessing the issue is a combination of the
_FuncWrapper+report.metrics.summarizeside (without_FuncWrapperreport.metrics.summarizeworks fine, trying_FuncWrapperwith a simple function with type annotations doesn't reproduce the issue).Looking at the skore code it seems to mix descriptors + advanced typing, so the key for a reproducer without skore lies in understanding what combinations of advanced functionalities create the issue. I tried a few things but could not find the exact combination ...
[-]python==3.14/cloudpickle==3.1.2: unable to pickle[/-][+]`TypeError: cannot pickle '_abc._abc_data' object` with python 3.14 and cloudpickle 3.1.2[/+]ogrisel commentedon Dec 22, 2025
Thanks for the skore-based reproducer and the initial investigation. However, I wonder if the cause of the problem comes from cloudpickle itself: I don't see any dynamic class or function in the reproducer, so I don't see why cloudpickle-specific features would be needed for that case.
Indeed, I can reproduce a similar problem with the
dumpsfunction of the pickle module of CPython 3.14:Details
I checked, and that same code works with Python 3.13.
So maybe there is something wrong with either the
_MetricsAccessorclass definition, or_FuncWrapperor CPython 3.14 annotations.ogrisel commentedon Dec 22, 2025
I would be great to craft a reproducer that only depends on CPython and its standard library.
ogrisel commentedon Dec 22, 2025
Here is a more minimal reproducer:
The first call to
dumpsworks fine but the second fails. So I suspect that the wrapper needs to do something special to be picklable to deal with annotated callables on Python 3.14.ogrisel commentedon Dec 22, 2025
I reported a variant of the above minimal reproducer upstream: python/cpython#143067
lesteve commentedon Dec 22, 2025
The same snippet as python/cpython#143067 works fine with
cloudpickle.dumpsthough, right?ogrisel commentedon Dec 22, 2025
Indeed. Things might be more complicated then...
Still I think it's worth investigating what's needed to restore regular picklability for the minimal reproducer with CPython 3.14 before debugging cloudpickle specific things on the more complex setting. Maybe solving the simple case will also solve the complex case.
auguste-probabl commentedon Apr 16, 2026
May be closed by python/cpython#137814
ogrisel commentedon Apr 16, 2026
We need to test against a local buid or nightly build of both the Python 3.14 and the 3.15 branches.
thomass-dev commentedon Apr 16, 2026
@ogrisel sounds good on our side with
python==3.14.4probabl-ai/skore#2771.Edit: but the minimal reproducer continues to fail.
BioGeek commentedon Jun 8, 2026
I created a PR with a fix: #594
ogrisel commentedon Jul 2, 2026
I built Python's
mainbranch and the reproducer of #585 (comment) no longer fails.ogrisel commentedon Jul 2, 2026
I also tried with Python 3.14.6 and the reproducer passes as well (while it fails on 3.14.4).
ogrisel commentedon Jul 2, 2026
The test case of #594 fails with 3.14.6 though:
BioGeek commentedon Jul 2, 2026
@ogrisel I updated my PR #594 and validated that it now works on Python 3.14.4, 3.14.6 and 3.15.0a7.
ogrisel commentedon Jul 3, 2026
Thanks @BioGeek. Before proceeding with the review, I am pondering whether this can still be considered by a regression in CPython or not. If so we should try to report a minimal reproducer upstream and maybe consider #594 as a temporary workaround rather than a definitive fix.
ogrisel commentedon Jul 3, 2026
After taking a deeper look, I don't think that the problem that remains can be considered's a regression in CPython but I am not sure what's the cleanest way to deal with it either.
j-adamczyk commentedon Sep 18, 2026
@ogrisel could you please consider merging this temporary fix PR? It would enable us to dump scikit-fingerprints to support Python 3.14, as we depend on cloudpickle. Python 3.15 will be released soon, and being 2 versions behind starts to become inconvenient.
BioGeek commentedon Sep 23, 2026
@ogrisel I opened #603 as an alternative fix for this issue.
Part of this is already fixed upstream. The root cause is CPython gh-137814. Fixed in 3.14.5 by gh-148221 and on main by gh-137842. On 3.14.5+ the module-level reproducer of this issue already works with cloudpickle master. @j-adamczyk that may well unblock scikit-fingerprints today, without waiting for a cloudpickle release. What still fails on every 3.14+ build is the case where the annotated class itself is pickled by value (defined in
__main__, in a notebook, or otherwise dynamic).Test suite is green on 3.12, 3.14.4, 3.14.6 and 3.15.0b3