[pypy-commit] pypy default: merge heads
gutworth
noreply at buildbot.pypy.org
Sun Mar 11 22:56:39 CET 2012
Author: Benjamin Peterson <benjamin at python.org>
Branch:
Changeset: r53305:81acfc4eadac
Date: 2012-03-11 14:54 -0700
http://bitbucket.org/pypy/pypy/changeset/81acfc4eadac/
Log: merge heads
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
@@ -91,9 +91,18 @@
if s[i] == "{":
i += 1
markup_follows = False
- # Attach literal data
+ # Attach literal data, ending with { or }
out.append_slice(s, last_literal, i - 1)
if not markup_follows:
+ if self.parser_list_w is not None:
+ end_literal = i - 1
+ assert end_literal > last_literal
+ literal = self.template[last_literal:end_literal]
+ w_entry = space.newtuple([
+ space.wrap(literal),
+ space.w_None, space.w_None, space.w_None])
+ self.parser_list_w.append(w_entry)
+ self.last_end = i
last_literal = i
continue
nested = 1
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
@@ -11,6 +11,7 @@
assert self.s("}}").format() == self.s("}")
assert self.s("{} {{ {}").format(1, 2) == self.s("1 { 2")
assert self.s("{{}}").format() == self.s("{}")
+ assert self.s("{{{{").format() == self.s("{{")
def test_empty(self):
assert self.s().format() == self.s()
@@ -385,6 +386,12 @@
for x in l[0]:
assert isinstance(x, unicode)
+ def test_formatter_parser_escape(self):
+ l = list("{{a}}"._formatter_parser())
+ assert l == [('{', None, None, None), ('a}', None, None, None)]
+ l = list("{{{{"._formatter_parser())
+ assert l == [('{', None, None, None), ('{', None, None, None)]
+
def test_formatter_field_name_split(self):
first, rest = ''._formatter_field_name_split()
assert first == ''
More information about the pypy-commit
mailing list