[issue13790] In str.format an incorrect error message for list, tuple, dict, set

Eric V. Smith report at bugs.python.org
Sun Jan 15 06:57:35 CET 2012


Eric V. Smith <eric at trueblade.com> added the comment:

I agree it's not the best error message. What's happening is that these types (list, tuple, etc.) do not implement __format__, so object.__format__ is used. It returns str(self). Then the resulting string is formatted with the given format_spec. Since str does not support the 'd' format type, the error you see is raised.

I'm open to suggestions on how to improve this, but I don't see how it's possible given what str.__format__ knows when it generates the error.

----------
assignee:  -> eric.smith
nosy: +eric.smith
versions: +Python 3.2, Python 3.3 -Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13790>
_______________________________________


More information about the Python-bugs-list mailing list