[issue39694] Incorrect dictionary unpacking when calling str.format

Serhiy Storchaka report at bugs.python.org
Thu Dec 9 05:07:38 EST 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I disagree, but does not insists if other core developers have other opinion.

This is a special case which breaks the rules. The Python language specification does not support non-string keywords. You cannot implement this "feature" in Python. And it is not compatible with other implementations (PyPy):

>>>> ''.format(**{1:2})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: format() keywords must be strings, not 'int'

It would be understandable to not enforce this limitation if it has significant costs. But in this case it costs almost nothing.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39694>
_______________________________________


More information about the Python-bugs-list mailing list