mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-85795: Raise a clear error when super()
is used in typing.NamedTuple
subclasses (#130082)
This commit is contained in:
parent
5e73ece95e
commit
293fa3433e
4 changed files with 27 additions and 0 deletions
|
@ -2889,6 +2889,9 @@ _special = frozenset({'__module__', '__name__', '__annotations__', '__annotate__
|
|||
class NamedTupleMeta(type):
|
||||
def __new__(cls, typename, bases, ns):
|
||||
assert _NamedTuple in bases
|
||||
if "__classcell__" in ns:
|
||||
raise TypeError(
|
||||
"uses of super() and __class__ are unsupported in methods of NamedTuple subclasses")
|
||||
for base in bases:
|
||||
if base is not _NamedTuple and base is not Generic:
|
||||
raise TypeError(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue