From 75dda3b12d689d1e90ae198cd9509e529826557a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 25 Jun 2022 18:45:46 +0300 Subject: [PATCH] [3.10] gh-94245: Fix pickling and copying of typing.Tuple[()] (GH-94260) --- Lib/typing.py | 3 ++- .../next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst diff --git a/Lib/typing.py b/Lib/typing.py index 086d0f3f9594c7..9f8710b9f773b8 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1099,7 +1099,8 @@ def __reduce__(self): else: origin = self.__origin__ args = tuple(self.__args__) - if len(args) == 1 and not isinstance(args[0], tuple): + if len(args) == 1 and (not isinstance(args[0], tuple) or + origin is Tuple and not args[0]): args, = args return operator.getitem, (origin, args) diff --git a/Misc/NEWS.d/next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst b/Misc/NEWS.d/next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst new file mode 100644 index 00000000000000..de84918d5eceea --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst @@ -0,0 +1 @@ +Fix pickling and copying of ``typing.Tuple[()]``.