From a94e6272f16381349dbed74cdb738ec8ae23b4fe Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 4 Apr 2020 21:31:30 +0300 Subject: bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363) --- Lib/typing.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/typing.py') diff --git a/Lib/typing.py b/Lib/typing.py index 5351883000..99355d0066 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1728,6 +1728,9 @@ class NamedTupleMeta(type): def __new__(cls, typename, bases, ns): if ns.get('_root', False): return super().__new__(cls, typename, bases, ns) + if len(bases) > 1: + raise TypeError("Multiple inheritance with NamedTuple is not supported") + assert bases[0] is NamedTuple types = ns.get('__annotations__', {}) nm_tpl = _make_nmtuple(typename, types.items()) defaults = [] -- cgit v1.2.1