New submission from Akos Kiss <akosthek...@gmail.com>:
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. ---------- messages: 362304 nosy: Akos Kiss priority: normal severity: normal status: open title: Incorrect dictionary unpacking when calling str.format type: behavior versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39694> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com