← index #10109Issue #3281
Duplicate · high · value 4.154
QUERY · ISSUE

Calling method with multiple named arguments does not raise SyntaxError

openby dlechopened 2022-11-27updated 2024-09-02
bugpy-core

It actually fixes a bug unrelated to double ** usage. Eg the following would previously pass without error:

def f(**x):
    print(x)

f(a=1, a=2)

Can you please add a test for that case as well?

Originally posted by @dpgeorge in https://github.com/micropython/micropython/issues/10095#issuecomment-1328186336

CANDIDATE · ISSUE

Repeated keyword argument should cause SyntaxError, not TypeError

openby alex-robbinsopened 2017-08-22updated 2024-08-28
bug

CPython:

>>> def f(x): pass
... 
>>> f(x=1, x=1)
  File "<stdin>", line 1
SyntaxError: keyword argument repeated

MicroPython:

>>> def f(x): pass
... 
>>> f(x=1, x=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function got multiple values for argument 'x'

Nitpicky? Yes. But I doubt fixing this would change code size, so...

See also #466. I would have submitted a patch instead of an issue, but it looks like that exception can be raised from two different places, and I don't know the difference.

Thanks,
Alex

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied