From 0cee0a662c28aa3021e3c18eb6ab7b3474b3f796 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 8 Feb 2024 17:06:06 -0800 Subject: [PATCH] add news entry and comment --- Lib/typing.py | 3 +++ .../Library/2024-02-08-17-04-58.gh-issue-112903.SN_vUs.rst | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-02-08-17-04-58.gh-issue-112903.SN_vUs.rst diff --git a/Lib/typing.py b/Lib/typing.py index 71680221541991..3e533fb0f56cfd 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1136,6 +1136,9 @@ def __mro_entries__(self, bases): if self.__origin__ not in bases: res.append(self.__origin__) i = bases.index(self) + # The goal here is to only add Generic to the MRO if nothing else in the + # MRO is already a subclass of Generic; otherwise we risk failure to + # linearize a consistent MRO. for b in bases[i+1:]: if isinstance(b, _BaseGenericAlias): break diff --git a/Misc/NEWS.d/next/Library/2024-02-08-17-04-58.gh-issue-112903.SN_vUs.rst b/Misc/NEWS.d/next/Library/2024-02-08-17-04-58.gh-issue-112903.SN_vUs.rst new file mode 100644 index 00000000000000..1d65e767551008 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-02-08-17-04-58.gh-issue-112903.SN_vUs.rst @@ -0,0 +1,2 @@ +Fix "issubclass() arg 1 must be a class" errors in certain cases of multiple +inheritance with generic aliases.