summaryrefslogtreecommitdiffstats
path: root/Lib/copyreg.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-07-24 18:26:02 (GMT)
committerGitHub <noreply@github.com>2021-07-24 18:26:02 (GMT)
commit435a0334d341e5f8faed594d9f015746bb7845db (patch)
tree5c090299361ae9dabe002f2936044a01b1022b16 /Lib/copyreg.py
parent4f5980a4f57dab68b9137304f58bd08891d43d5a (diff)
downloadcpython-435a0334d341e5f8faed594d9f015746bb7845db.zip
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.gz
cpython-435a0334d341e5f8faed594d9f015746bb7845db.tar.bz2
bpo-44676: Serialize the union type using only public API (GH-27323)
Remove also the _from_args() constructor.
Diffstat (limited to 'Lib/copyreg.py')
-rw-r--r--Lib/copyreg.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/copyreg.py b/Lib/copyreg.py
index 7ab8c12..356db6f 100644
--- a/Lib/copyreg.py
+++ b/Lib/copyreg.py
@@ -36,6 +36,12 @@ else:
pickle(complex, pickle_complex, complex)
+def pickle_union(obj):
+ import functools, operator
+ return functools.reduce, (operator.or_, obj.__args__)
+
+pickle(type(int | str), pickle_union)
+
# Support for pickling new-style objects
def _reconstructor(cls, base, state):