[issue12014] str.format parses replacement field incorrectly

Eric V. Smith report at bugs.python.org
Fri Jun 3 21:47:49 CEST 2011


Eric V. Smith <eric at trueblade.com> added the comment:

PEP 3101 defines format strings as intermingled character data and markup. Markup defines replacement fields and is delimited by braces. Only after markup is extracted does the PEP talk about interpreting the contents of the markup.

So, given "{0[a}b]}" the parser first parses out the character data and the markup. The first piece of markup is "{0[a}". That gives a syntax error because it's missing a right bracket.

I realize you'd like the parser to find the markup as the entire string, but that's not how I read the PEP.

----------

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


More information about the Python-bugs-list mailing list