[issue39694] Incorrect dictionary unpacking when calling str.format

Serhiy Storchaka report at bugs.python.org
Thu Feb 20 09:16:16 EST 2020


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

See similar issue for SimpleNamespace: https://bugs.python.org/issue31655.

We should add a similar check in str.format(). Accepting a non-string keys is an implementation detail. There is no guarantee that it works in other implementations.

It should not hit performance, because the kwargs dict is usually small, the check is cheap, and formatting itself can be expensive. For the case when you need to pass a huge dict and use only few items from it, you can use str.format_map().

----------

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


More information about the Python-bugs-list mailing list