circuitpython/tests/basics/fun_calldblstar.py
Damien George 3280788195 py/runtime: Check that keys in dicts passed as ** args are strings.
Prior to this patch the code would crash if a key in a ** dict was anything
other than a str or qstr.  This is because mp_setup_code_state() assumes
that keys in kwargs are qstrs (for efficiency).

Thanks to @jepler for finding the bug.
2018-03-30 11:13:32 +11:00

23 lines
383 B
Python

# test calling a function with keywords given by **dict
def f(a, b):
print(a, b)
f(1, **{'b':2})
f(1, **{'b':val for val in range(1)})
try:
f(1, **{len:2})
except TypeError:
print('TypeError')
# test calling a method with keywords given by **dict
class A:
def f(self, a, b):
print(a, b)
a = A()
a.f(1, **{'b':2})
a.f(1, **{'b':val for val in range(1)})