diff options
author | RĂ©mi Lapeyre <remi.lapeyre@lenstra.fr> | 2020-05-24 21:12:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 21:12:57 (GMT) |
commit | c73914a562580ae72048876cb42ed8e76e2c83f9 (patch) | |
tree | c2530e91a3790121ef7d4a4650a0bdc7c91f1eeb /Lib/ast.py | |
parent | 59f5022b5d3e5fcc60ac61cc256b627decf8ee68 (diff) | |
download | cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.zip cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.tar.gz cpython-c73914a562580ae72048876cb42ed8e76e2c83f9.tar.bz2 |
bpo-36290: Fix keytword collision handling in AST node constructors (GH-12382)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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) |