summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorYurii Karabas <1998uriyyo@gmail.com>2021-08-18 19:08:32 (GMT)
committerGitHub <noreply@github.com>2021-08-18 19:08:32 (GMT)
commita3a4d20d6798aa2975428d51f3a4f890248810cb (patch)
tree96f00098fbd62759b13d7997efd315047da3ca18 /Lib/typing.py
parent6fb62b42f4db56ed5efe0ca4c1059049276c1083 (diff)
downloadcpython-a3a4d20d6798aa2975428d51f3a4f890248810cb.zip
cpython-a3a4d20d6798aa2975428d51f3a4f890248810cb.tar.gz
cpython-a3a4d20d6798aa2975428d51f3a4f890248810cb.tar.bz2
bpo-44524: Fix cryptic TypeError message when trying to subclass special forms in `typing` (GH-27710)
This was a Python 3.9 regression.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 51468ae..eeeb295 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1086,6 +1086,9 @@ class _GenericAlias(_BaseGenericAlias, _root=True):
return operator.getitem, (origin, args)
def __mro_entries__(self, bases):
+ if isinstance(self.__origin__, _SpecialForm):
+ raise TypeError(f"Cannot subclass {self!r}")
+
if self._name: # generic version of an ABC or built-in class
return super().__mro_entries__(bases)
if self.__origin__ is Generic: