summaryrefslogtreecommitdiffstats
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-05-01 15:19:06 (GMT)
committerGitHub <noreply@github.com>2023-05-01 15:19:06 (GMT)
commit99aab610622fc4b4c4fe56b77c0760cf77066a53 (patch)
tree39013f1f2980f70b1c0e0de2eb3abc12e9b6ba31 /Lib/dataclasses.py
parente1476942525ae847875dab55541bef4a8a99dd3d (diff)
downloadcpython-99aab610622fc4b4c4fe56b77c0760cf77066a53.zip
cpython-99aab610622fc4b4c4fe56b77c0760cf77066a53.tar.gz
cpython-99aab610622fc4b4c4fe56b77c0760cf77066a53.tar.bz2
gh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (#104041)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index a73cdc2..b0b8a77 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1227,8 +1227,10 @@ def _add_slots(cls, is_frozen, weakref_slot):
if is_frozen:
# Need this for pickling frozen classes with slots.
- cls.__getstate__ = _dataclass_getstate
- cls.__setstate__ = _dataclass_setstate
+ if '__getstate__' not in cls_dict:
+ cls.__getstate__ = _dataclass_getstate
+ if '__setstate__' not in cls_dict:
+ cls.__setstate__ = _dataclass_setstate
return cls