[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 01:34:55 CET 2012


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

Eric V. Smith <report at bugs.python.org> wrote:
> As I look at it a little closer, I think I'm going to change the message to:
> "Invalid format type specified". The code has determined that instead of a
> type that's a single character long, it's received "xx10d". That's because
> "xx" doesn't match any of "[[fill]align][sign][#][0][width][,][.precision]",
> so it must be the "[type]" field.

I think this has the potential of being more confusing for people who are
not very familiar with the format specification mini-language. I didn't
look at the code now, but would the message also be raised for this spec?

    format(9, "xx10f")

> I'm open to a better message, though.

IMO "invalid format specifier" is fine. Even the existing error message
is not really terrible.

----------

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


More information about the Python-bugs-list mailing list