From 435a0334d341e5f8faed594d9f015746bb7845db Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 24 Jul 2021 21:26:02 +0300 Subject: bpo-44676: Serialize the union type using only public API (GH-27323) Remove also the _from_args() constructor. --- Lib/copyreg.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Lib/copyreg.py') diff --git a/Lib/copyreg.py b/Lib/copyreg.py index 7ab8c128eb..356db6f083 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): -- cgit v1.2.1