summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-13 03:08:49 (GMT)
committerGitHub <noreply@github.com>2022-04-13 03:08:49 (GMT)
commit15537c51c188a6633248c25d211d5216e673aee3 (patch)
tree6ccc7404181320732cd6c02377d0fc8041b00a0e /Lib/typing.py
parent0859368335d470b9ff33fc53ed9a85ec2654b278 (diff)
downloadcpython-15537c51c188a6633248c25d211d5216e673aee3.zip
cpython-15537c51c188a6633248c25d211d5216e673aee3.tar.gz
cpython-15537c51c188a6633248c25d211d5216e673aee3.tar.bz2
bpo-43224: Forbid TypeVar substitution with Unpack (GH-32031)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 46fc722..1b584be 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -965,6 +965,8 @@ class TypeVar(_Final, _Immutable, _BoundVarianceMixin, _root=True):
def __typing_subst__(self, arg):
msg = "Parameters to generic types must be types."
arg = _type_check(arg, msg, is_argument=True)
+ if (isinstance(arg, _GenericAlias) and arg.__origin__ is Unpack):
+ raise TypeError(f"{arg} is not valid as type argument")
return arg