Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r62895:6b3a588d8647
Date: 2013-03-30 12:28 -0700
http://bitbucket.org/pypy/pypy/changeset/6b3a588d8647/

Log:    kill the keep_zero cornercase

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -43,7 +43,7 @@
                space.wrap('not all arguments converted '
                             'during string formatting'))
 
-    def std_wp_int(self, r, prefix='', keep_zero=False):
+    def std_wp_int(self, r, prefix=''):
         # use self.prec to add some '0' on the left of the number
         if self.prec >= 0:
             if self.prec > 1000:
@@ -57,8 +57,6 @@
                     r = '-' + '0'*padding + r[1:]
                 else:
                     r = '0'*padding + r
-            elif self.prec == 0 and r == '0' and not keep_zero:
-                r = ''
         self.std_wp_number(r, prefix)
 
     def fmt_d(self, w_value):
@@ -91,7 +89,7 @@
             prefix = '0o'
         else:
             prefix = ''
-        self.std_wp_int(r, prefix, keep_zero=True)
+        self.std_wp_int(r, prefix)
 
     fmt_i = fmt_d
     fmt_u = fmt_d
diff --git a/pypy/objspace/std/test/test_stringformat.py 
b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -182,14 +182,15 @@
         assert "%3s" % a == '  a'
         assert "%-3s"% a == 'a  '
 
-    def test_prec_cornercase(self):
+    def test_prec_zero(self):
         z = 0
-        assert "%.0x" % z == ''
-        assert "%.x" % z == ''
-        assert "%.0d" % z == ''
-        assert "%.i" % z == ''
-        assert "%.0o" % z == ''
-        assert "%.o" % z == ''
+        assert "%.0x" % z == '0'
+        assert "%.0X" % z == '0'
+        assert "%.x" % z == '0'
+        assert "%.0d" % z == '0'
+        assert "%.i" % z == '0'
+        assert "%.0o" % z == '0'
+        assert "%.o" % z == '0'
 
     def test_prec_string(self):
         a = 'a'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to