Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r89534:ce9b5b7a5f2d Date: 2017-01-12 23:51 +0100 http://bitbucket.org/pypy/pypy/changeset/ce9b5b7a5f2d/
Log: More tests and fixes diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py --- a/pypy/objspace/std/newformat.py +++ b/pypy/objspace/std/newformat.py @@ -165,6 +165,12 @@ conversion = None i += 1 return s[start:end_name], conversion, i + elif c == "[": + while i + 1 < end and s[i + 1] != "]": + i += 1 + elif c == "{": + raise oefmt(self.space.w_ValueError, + "unexpected '{' in field name") i += 1 return s[start:end], None, end diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py --- a/pypy/objspace/std/test/test_newformat.py +++ b/pypy/objspace/std/test/test_newformat.py @@ -195,6 +195,11 @@ assert self.s('x{[3]}y').format(['a', 'b', 'c', 'd', 'e']) == 'xdy' assert self.s('x{[[]}y').format({'[': 'a'}) == 'xay' assert self.s('x{[{]}y').format({'{': 'a'}) == 'xay' + assert self.s("x{[:]}y").format({":" : "a"}) == "xay" + assert self.s("x{[!]}y").format({"!" : "a"}) == "xay" + raises(ValueError, self.s("{a{}b}").format, 42) + raises(ValueError, self.s("{a{b}").format, 42) + raises(ValueError, self.s("{[}").format, 42) class AppTestUnicodeFormat(BaseStringFormatTests): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit