[issue5247] Unhelpful error message with str.format()
report at bugs.python.org
Sun Feb 15 22:06:47 CET 2009
Eric Smith <eric at trueblade.com> added the comment:
The attached patch (against trunk) changes the message.
However, it has at least one unintended consequence. If you have an
object with no __format__, it gets converted to a string, which is then
formatted. So you get:
' 0j '
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown presentation type x for str
I'm calling format on an complex number, but the error says "str". The
error is correct, because the complex number has been converted to a
string before the formatting mechanism can get the actual type. I think
we'll have to live with this if we add the type to the error message.
Added file: http://bugs.python.org/file13102/issue5247.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list