Message232956
I came across unexpected behavior working with unpacking keyword arguments in Python 3. It appears to be related to the automatic normalization of unicode characters to NFKC (PEP 3131), which converts e.g. MICRO SIGN to GREEK SMALL LETTER MU. This conversion is applied to regular keyword arguments but not when unpacking arguments via **.
This issue arose while I was working with some automatically generated namedtuple classes, but I was able to reproduce it with a simple function:
def test(μ):
print(μ)
>>> test(µ="test1") # chr(181)
test1
>>> test(μ="test2") # chr(956)
test2
>>> test(**{'μ': "test3"}) # chr(956)
test3
>>> test(**{'µ': "test4"}) # chr(181)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: test() got an unexpected keyword argument 'µ'
I can obviously work around this, but wanted to bring it up in case it's a bug. My naive expectation would be that unpacked ** keys should be treated exactly like normal keyword arguments. |
|
Date |
User |
Action |
Args |
2014-12-20 02:37:18 | sheppard | set | recipients:
+ sheppard, vstinner, ezio.melotti |
2014-12-20 02:37:18 | sheppard | set | messageid: <1419043038.74.0.103514960492.issue23091@psf.upfronthosting.co.za> |
2014-12-20 02:37:18 | sheppard | link | issue23091 messages |
2014-12-20 02:37:17 | sheppard | create | |
|