diff options
| author | David Lechner <david@pybricks.com> | 2022-11-26 12:12:00 -0600 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-11-28 11:23:22 +1100 |
| commit | d5181034f2daa11199a1785e391c0fa8eb672de3 (patch) | |
| tree | 7e0929e24420ddc40276351cf81360c853a799bd /tests/basics/fun_calldblstar.py | |
| parent | cc26bf7406dac7822de347d14a9935c101d7e8aa (diff) | |
py/bc: Fix checking for duplicate **kwargs.
The code was already checking for duplicate kwargs for named parameters but
if `**kwargs` was given as a parameter, it did not check for multiples of
the same argument name.
This fixes the issue by adding an addition test to catch duplicates and
adds a test to exercise the code.
Fixes issue #10083.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'tests/basics/fun_calldblstar.py')
| -rw-r--r-- | tests/basics/fun_calldblstar.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/fun_calldblstar.py b/tests/basics/fun_calldblstar.py index 4a503698f..0308f42bd 100644 --- a/tests/basics/fun_calldblstar.py +++ b/tests/basics/fun_calldblstar.py @@ -20,3 +20,13 @@ class A: a = A() a.f(1, **{'b':2}) a.f(1, **{'b':val for val in range(1)}) + +# test for duplicate keys in **kwargs not allowed + +def f1(**kwargs): + print(kwargs) + +try: + f1(**{'a': 1, 'b': 2}, **{'b': 3, 'c': 4}) +except TypeError: + print('TypeError') |
