summaryrefslogtreecommitdiffstats
path: root/Lib/copyreg.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-06 17:00:14 (GMT)
committerGitHub <noreply@github.com>2022-04-06 17:00:14 (GMT)
commit884eba3c76916889fd6bff3b37b8552bfb4f9566 (patch)
tree51fd55d6170cdff327ac11d70f1e5ff1aa7e735a /Lib/copyreg.py
parentf82f9ce3239b9a7e6ffa278658dd9858f64a3c14 (diff)
downloadcpython-884eba3c76916889fd6bff3b37b8552bfb4f9566.zip
cpython-884eba3c76916889fd6bff3b37b8552bfb4f9566.tar.gz
cpython-884eba3c76916889fd6bff3b37b8552bfb4f9566.tar.bz2
bpo-26579: Add object.__getstate__(). (GH-2821)
Copying and pickling instances of subclasses of builtin types bytearray, set, frozenset, collections.OrderedDict, collections.deque, weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes implemented as slots.
Diffstat (limited to 'Lib/copyreg.py')
-rw-r--r--Lib/copyreg.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/copyreg.py b/Lib/copyreg.py
index 356db6f..c8a52a2 100644
--- a/Lib/copyreg.py
+++ b/Lib/copyreg.py
@@ -89,6 +89,10 @@ def _reduce_ex(self, proto):
except AttributeError:
dict = None
else:
+ if (type(self).__getstate__ is object.__getstate__ and
+ getattr(self, "__slots__", None)):
+ raise TypeError("a class that defines __slots__ without "
+ "defining __getstate__ cannot be pickled")
dict = getstate()
if dict:
return _reconstructor, args, dict