[pypy-issue] [issue1081] string.Formatter does not unescape double braces

Simon Sapin tracker at bugs.pypy.org
Fri Mar 9 17:40:39 CET 2012


New submission from Simon Sapin <simon.sapin at kozea.fr>:

The Formatter class of the string module is supposed to implement the same
functionality as the str.format method, but on PyPy 1.8.0 it (incorrectly) does
not unescape double braces.

Test case:

    import string; print string.Formatter().format("{{a}}", a=42)

Expected (CPython) output: {a}
PyPy output: {{a}}

Note that str.format('{{a}}', a=42) works fine in both CPython and PyPy.

The string.py stdlib module is identical in CPython 2.7.2 and PyPy 1.8.0, but it
calls the str._formatter_parser() method, where the results differ:

CPython: [('{', None, None, None), ('a}', None, None, None)]
PyPy: [('{{a}}', None, None, None)]

(This output is documented here:
http://docs.python.org/release/2.7/library/string.html#string.Formatter.parse )

----------
messages: 4056
nosy: SimonSapin, pypy-issue
priority: bug
status: unread
title: string.Formatter does not unescape double braces

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1081>
________________________________________


More information about the pypy-issue mailing list