Open
Description
When using the following library[1] I experienced a weird error:
Frozen module / copied into some importable path makes no difference.
I'm having the following interaction with the repl:
>>> from mp_modbus_master import modbus_rtu_master
>>> modbus_rtu_master()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/TMP/mp_modbus_master.py", line 513, in __init__
TypeError: unexpected keyword argument 'rtu'
>>>
Looking at the code, though, (https://github.com/eydam-prototyping/mp_modbus/blob/master/mp_modbus_master.py#L513) there's no kwarg rtu
.
The only occurrence of the string "rtu" is the default value to the kwarg ms_type
in that line.
That this string "rtu" is indeed the one seen as kwarg by mpy is confirmed by changing it to "XXX" - whereas mpy then complains about TypeError: unexpected keyword argument 'XXX'
Minimal test case showing this behaviour (thanks to @jimmo):
def a(x="y"):
print(x)
def b(*args):
a(x="z", *args)
b()
resulting in
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "<stdin>", line 5, in b
TypeError: unexpected keyword argument 'z'