[issue28385] Bytes objects should reject all formatting codes with an error message

Serhiy Storchaka report at bugs.python.org
Mon Oct 31 08:56:51 EDT 2016


Serhiy Storchaka added the comment:

But on other hand, the error depends on the value of format specifier:

>>> format('abc', '')
'abc'
>>> format('abc', 'j')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'j' for object of type 'str'
>>> format([1, 2, 3], '')
'[1, 2, 3]'
>>> format([1, 2, 3], 'j')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to list.__format__

If keep TypeError I think it would be better to restore former error message "non-empty format string".

----------

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


More information about the Python-bugs-list mailing list