[pypy-commit] pypy py3.5: More tests and fixes

arigo pypy.commits at gmail.com
Thu Jan 12 17:52:29 EST 2017


Author: Armin Rigo <arigo at 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):


More information about the pypy-commit mailing list