mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
bpo-44524: Fix cryptic TypeError message when trying to subclass special forms in typing
(GH-27710)
This was a Python 3.9 regression.
(cherry picked from commit a3a4d20d67
)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
This commit is contained in:
parent
cd986e9031
commit
81fa08c5ea
3 changed files with 21 additions and 0 deletions
|
@ -1081,6 +1081,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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue