-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed as duplicate of#137814
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The following minimal reproducer used to run without exception with CPython 3.13 and earlier but started to fail with CPython 3.14.0.
The problem only happens with the third call to dumps, hence is related to the combinations of functools.update_wrapper and a type annotated function.
from functools import update_wrapper
from pickle import dumps
class _FuncWrapper:
def __init__(self, function):
self.function = function
update_wrapper(self, self.function)
def some_function_without_annotations(x):
return x
def some_function_with_annotations(x: str) -> str:
return x
dumps(some_function_with_annotations) # ok
dumps(_FuncWrapper(some_function_without_annotations)) # ok
dumps(_FuncWrapper(some_function_with_annotations)) # raises---------------------------------------------------------------------------
PicklingError Traceback (most recent call last)
Cell In[0], line 22
20 dumps(some_function_with_annotations)
21 dumps(_FuncWrapper(some_function_without_annotations))
---> 22 dumps(_FuncWrapper(some_function_with_annotations))
PicklingError: Can't pickle <function __annotate__ at 0x108351170>: it's not the same object as __main__.__annotate__
when serializing dict item '__annotate__'
when serializing _FuncWrapper state
when serializing _FuncWrapper objectCPython versions tested on:
3.14
Operating systems tested on:
macOS
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done