summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-04 18:31:30 (GMT)
committerGitHub <noreply@github.com>2020-04-04 18:31:30 (GMT)
commita94e6272f16381349dbed74cdb738ec8ae23b4fe (patch)
tree88b84259573c0752ded1fce71c76094f8cb7989a /Lib/typing.py
parent1ae6445391cc3519733df69a4448059d6eff3c6f (diff)
downloadcpython-a94e6272f16381349dbed74cdb738ec8ae23b4fe.zip
cpython-a94e6272f16381349dbed74cdb738ec8ae23b4fe.tar.gz
cpython-a94e6272f16381349dbed74cdb738ec8ae23b4fe.tar.bz2
bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 5351883..99355d0 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 = []