Author: Tyler Wade <[email protected]>
Branch: utf8-unicode2
Changeset: r72726:7f527aa7b8f1
Date: 2014-08-09 02:12 -0500
http://bitbucket.org/pypy/pypy/changeset/7f527aa7b8f1/

Log:    str._formatter_parser is apparently part of the public api

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
@@ -340,11 +340,19 @@
                     space = self.space
                     startm1 = start - 1
                     assert startm1 >= self.last_end
+
+                    w_conv = space.w_None
+                    if conversion != -1:
+                        if self.is_unicode:
+                            w_conv = space.wrap(utf8chr((conversion)))
+                        else:
+                            w_conv = space.wrap(chr((conversion)))
+
                     w_entry = space.newtuple([
                         space.wrap(self.template[self.last_end:startm1]),
                         space.wrap(name),
                         space.wrap(spec),
-                        space.wrap(conversion)])
+                        w_conv])
                     self.parser_list_w.append(w_entry)
                     self.last_end = end + 1
                 return self.empty
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
@@ -382,29 +382,29 @@
         assert l == [('abcd', None, None, None)]
         #
         l = list('ab{0}cd'._formatter_parser())
-        assert l == [('ab', '0', '', -1), ('cd', None, None, None)]
+        assert l == [('ab', '0', '', None), ('cd', None, None, None)]
         #
         l = list('{0}cd'._formatter_parser())
-        assert l == [('', '0', '', -1), ('cd', None, None, None)]
+        assert l == [('', '0', '', None), ('cd', None, None, None)]
         #
         l = list('ab{0}'._formatter_parser())
-        assert l == [('ab', '0', '', -1)]
+        assert l == [('ab', '0', '', None)]
         #
         l = list(''._formatter_parser())
         assert l == []
         #
         l = list('{0:123}'._formatter_parser())
-        assert l == [('', '0', '123', -1)]
+        assert l == [('', '0', '123', None)]
         #
         l = list('{0!x:123}'._formatter_parser())
-        assert l == [('', '0', '123', ord('x'))]
+        assert l == [('', '0', '123', 'x')]
         #
         l = list('{0!x:12{sdd}3}'._formatter_parser())
-        assert l == [('', '0', '12{sdd}3', ord('x'))]
+        assert l == [('', '0', '12{sdd}3', 'x')]
 
     def test_u_formatter_parser(self):
         l = list(u'{0!x:12{sdd}3}'._formatter_parser())
-        assert l == [(u'', u'0', u'12{sdd}3', ord(u'x'))]
+        assert l == [(u'', u'0', u'12{sdd}3', u'x')]
         for x in l[0][:-1]:
             assert isinstance(x, unicode)
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to