diff options
Diffstat (limited to 'Lib/ast.py')
| -rw-r--r-- | Lib/ast.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/ast.py b/Lib/ast.py index 52e51b4858..6a5b39e270 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -524,6 +524,13 @@ class _ABC(type): return type.__instancecheck__(cls, inst) def _new(cls, *args, **kwargs): + for key in kwargs: + if key not in cls._fields: + # arbitrary keyword arguments are accepted + continue + pos = cls._fields.index(key) + if pos < len(args): + raise TypeError(f"{cls.__name__} got multiple values for argument {key!r}") if cls in _const_types: return Constant(*args, **kwargs) return Constant.__new__(cls, *args, **kwargs) |
