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

py.user report at bugs.python.org
Sun Jan 15 06:31:19 CET 2012


New submission from py.user <port139 at yandex.ru>:

>>> '{0:d}'.format('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'str'
>>> '{0:d}'.format(1+1j)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'complex'
>>> '{0:d}'.format([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'str'
>>>

also strange behavior:
>>> '{0:s}'.format((1, 2, 3))
'(1, 2, 3)'
>>> '{0:10.5s}'.format([1, 2, 3])
'[1, 2     '
>>>

----------
components: Interpreter Core
messages: 151277
nosy: py.user
priority: normal
severity: normal
status: open
title: In str.format an incorrect error message for list, tuple, dict, set
type: behavior
versions: Python 3.1

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


More information about the Python-bugs-list mailing list