Open
Description
Bug report
Bug description:
This was a nasty bug to track down. I really don't have a clue why this would happen. It seems to be triggered under these conditions:
- A root class (
Root
) inherits fromABC
- There's diamond-shaped inheritance for a sub-subclass (
Multi
) - In
Root.__init_subclass__
, whenMulti
is initializing, a check is performed to see ifFirst
is a subclass ofSecond
First
is no longer a subclass of itself
from abc import ABC
class Root(ABC):
def __init_subclass__(cls, **kwargs):
if cls.__name__ == "Multi":
# issubclass(Second, First) # Wouldn't trigger the bug for Second
issubclass(First, Second) # Triggers the bug for First
issubclass(Second, First) # Doesn't trigger the bug for Second
class First(Root): ...
class Second(Root): ...
class Multi(First, Second): ...
assert not issubclass(First, First) # This is the bug.
assert issubclass(Second, Second)
print("bug!")
CPython versions tested on:
3.12
Operating systems tested on:
macOS