Closed
Description
Bug report
Bug description:
Below is a simplification of some classes that create the problem:
import typing
K = typing.TypeVar("K")
V = typing.TypeVar("V")
class BaseMap(typing.Mapping[K, V]): ...
class MutableMap(BaseMap[K, V], typing.MutableMapping[K, V]): ...
class MyMap(typing.Dict[K, V], MutableMap[K, V]): ...
Just entering these definitions in the REPL causes the error.
The stack trace (with info about variable b
):
b=__main__.MutableMap[~V]
type(b)=<class 'types.GenericAlias'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
class MyMap(typing.Dict[K, V], MutableMap[V]): ...
File "/home/russell/.pyenv/versions/3.13-dev/lib/python3.13/typing.py", line 1391, in __mro_entries__
return super().__mro_entries__(bases)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/home/russell/.pyenv/versions/3.13-dev/lib/python3.13/typing.py", line 1143, in __mro_entries__
if isinstance(b, _BaseGenericAlias) or issubclass(b, Generic):
~~~~~~~~~~^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class
This works "fine" before Python 3.13. If I swap the order of typing.Dict[K, V], MutableMap[V]
, the error no longer presents on 3.13.
I don't understand enough of intersection of these topics to know if this is now an expected error or something is considered wrong. This does seem related to #103369.
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done