[issue13811] In str.format, if invalid fill and alignment are specified, the text of the ValueError message is misleading.

Stefan Krah report at bugs.python.org
Thu Jan 19 00:40:41 CET 2012

Stefan Krah <stefan-usenet at bytereef.org> added the comment:

The text speaks about the regular case of a second character that
is not a valid alignment character, e.g.:

    format(3.222, ".2f")

Clearly the '2' fulfills this criterion, so the parser knows that the
leading '.' is *not* a fill character. This is all that the text says.

But even in your irregular case the text is still correct: After
it has been established that [[fill]align] is not present you have
to match the *whole string* with the rest of the grammar:


There is no match for "xx10d", hence the error.

BTW, I think this is out of scope for the tracker now. If you
have further questions, you could ask on:



Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list