[issue10379] locale.format() input regression
R. David Murray <rdmurray@bitdance.com> added the comment: Well, the distinction is that, before the bug fix that caused your issue, the 'format_string' method would use a regex to extract the % specifiers from the input string, and call 'format' to replace that % specifier with a properly localized result string. That is, 'format' was designed to handle a single % specifier with no extra text, basically as a helper method for format_string. The fact that it didn't reject extra text was, according to an internal comment, a defect of the implementation. (Passing any extra text would cause the implementation to fail to do the internationalization that was the entire reason for calling it.) When I fixed the bug I extracted the 'replace a single % specifier' code into an internal method, and made the format method live up to what I perceived to be its documented interface by rejecting extra input characters so that it could safely call the new internal substitution routine. Now, from the perspective of a *user* of the locale module, I fail to see the point in having both 'format' and 'format_string' exposed. If you want to format a single % specifier, just pass it to format_string. Thus my suggestion to make them both do the same thing (to cater to other code that may be calling format incorrectly) and then deprecate one of them (presumably format). To bad I didn't think of that when I fixed the original bug. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10379> _______________________________________
Barry A. Warsaw <barry@python.org> added the comment: On Nov 12, 2010, at 12:15 AM, R. David Murray wrote:
Now, from the perspective of a *user* of the locale module, I fail to see the point in having both 'format' and 'format_string' exposed. If you want to format a single % specifier, just pass it to format_string. Thus my suggestion to make them both do the same thing (to cater to other code that may be calling format incorrectly) and then deprecate one of them (presumably format).
+1
To bad I didn't think of that when I fixed the original bug.
Dang. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10379> _______________________________________
participants (2)
-
Barry A. Warsaw
-
R. David Murray