Message362304
My understanding was that in function calls, the keys in an **expression had to be strings. However, str.format seems to deviate from that and allows non-string keys in the mapping (and silently ignores them).
Please, see the transcript below:
>>> def f(): pass
...
>>> def g(): pass
...
>>> x = {None: ''}
>>> y = {1: ''}
>>> f(**x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings
>>> f(**y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings
>>> g(**x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: g() keywords must be strings
>>> g(**y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: g() keywords must be strings
>>> ''.format(**x)
''
>>> ''.format(**y)
''
I could reproduce this (incorrect?) behavior on macOS with python 3.4-3.7 and on Ubuntu 18.04 with python 3.6. |
|
Date |
User |
Action |
Args |
2020-02-20 10:03:23 | Akos Kiss | set | recipients:
+ Akos Kiss |
2020-02-20 10:03:23 | Akos Kiss | set | messageid: <1582193003.32.0.513659901276.issue39694@roundup.psfhosted.org> |
2020-02-20 10:03:23 | Akos Kiss | link | issue39694 messages |
2020-02-20 10:03:22 | Akos Kiss | create | |
|