[Python-checkins] [3.10] gh-94245: Fix pickling and copying of typing.Tuple[()] (GH-94260)

serhiy-storchaka webhook-mailer at python.org
Sat Jun 25 11:45:55 EDT 2022


https://github.com/python/cpython/commit/75dda3b12d689d1e90ae198cd9509e529826557a
commit: 75dda3b12d689d1e90ae198cd9509e529826557a
branch: 3.10
author: Serhiy Storchaka <storchaka at gmail.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2022-06-25T18:45:46+03:00
summary:

[3.10] gh-94245: Fix pickling and copying of typing.Tuple[()] (GH-94260)

files:
A Misc/NEWS.d/next/Library/2022-06-25-13-33-18.gh-issue-94245.-zQY1a.rst
M Lib/typing.py

diff --git a/Lib/typing.py b/Lib/typing.py
index 086d0f3f9594c..9f8710b9f773b 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 0000000000000..de84918d5ecee
--- /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[()]``.



More information about the Python-checkins mailing list