[issue10379] locale.format() input regression
Barry A. Warsaw
report at bugs.python.org
Wed Nov 10 00:58:54 CET 2010
Barry A. Warsaw <barry at python.org> added the comment:
Okay, so line 187 of locale.py has this test:
if not match or len(match.group())!= len(percent):
the problematic part is the len test. When format string is '%.0f KB' match.group() is '%.0f' but of course percent is the full string.
This seems like a bogus test, since clearly the given input is a valid format string. I'm not sure what the intent of this test is. The Python 2.6 test is:
if percent != '%':
which is perhaps too naive.
I guess I don't understand why this test is here. Wouldn't it make more sense to either just let any TypeError from _format() to percolate up, or to catch that TypeError and transform it into the ValueError? Why try to replicate the logic of str.__mod__()?
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list