[New-bugs-announce] [issue28146] Confusing error examples in str.format()
Serhiy Storchaka
report at bugs.python.org
Wed Sep 14 07:12:35 EDT 2016
New submission from Serhiy Storchaka:
For example:
>>> '{:04}'.format('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: '=' alignment not allowed in string format specifier
There is no any '=' in the format string.
>>> '{: }'.format('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Sign not allowed in string format specifier
There is no any sign ('+' or '-') in the format string.
There also an inconsistency between the wording of "something not allowed in string format specifier" and:
>>> '{:x}'.format('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'x' for object of type 'str'
>>> '{:xx}'.format('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format specifier
----------
components: Interpreter Core, Unicode
messages: 276415
nosy: ezio.melotti, haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Confusing error examples in str.format()
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28146>
_______________________________________
More information about the New-bugs-announce
mailing list