This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Akos Kiss
Recipients Akos Kiss
Date 2020-02-20.10:03:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582193003.32.0.513659901276.issue39694@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-20 10:03:23Akos Kisssetrecipients: + Akos Kiss
2020-02-20 10:03:23Akos Kisssetmessageid: <1582193003.32.0.513659901276.issue39694@roundup.psfhosted.org>
2020-02-20 10:03:23Akos Kisslinkissue39694 messages
2020-02-20 10:03:22Akos Kisscreate