mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363)
This commit is contained in:
parent
1ae6445391
commit
a94e6272f1
3 changed files with 12 additions and 0 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue