[pypy-svn] r75708 - in pypy/branch/fast-forward/pypy/objspace/std: . test

benjamin at codespeak.net benjamin at codespeak.net
Thu Jul 1 00:51:31 CEST 2010


Author: benjamin
Date: Thu Jul  1 00:51:28 2010
New Revision: 75708

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/newformat.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_newformat.py
Log:
fix more float formatting bugs

Modified: pypy/branch/fast-forward/pypy/objspace/std/newformat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/newformat.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/newformat.py	Thu Jul  1 00:51:28 2010
@@ -467,7 +467,7 @@
         if self._fill_char == "0" and self._align == "=":
             spec.n_min_width = self._width - extra_length
         if self._loc_thousands:
-            self._group_digits(spec, digits)
+            self._group_digits(spec, digits[to_number:])
             n_grouped_digits = len(self._grouped_digits)
         else:
             n_grouped_digits = spec.n_digits
@@ -500,7 +500,7 @@
         buf = []
         grouping = self._loc_grouping
         min_width = spec.n_min_width
-        i = 0
+        grouping_state = 0
         count = 0
         left = spec.n_digits
         n_ts = len(self._loc_thousands)
@@ -508,11 +508,11 @@
         done = False
         groupings = len(grouping)
         while True:
-            group = ord(grouping[i])
+            group = ord(grouping[grouping_state])
             if group > 0:
                 if group == 256:
                     break
-                i += 1
+                grouping_state += 1
                 previous = group
             else:
                 group = previous

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_newformat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_newformat.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_newformat.py	Thu Jul  1 00:51:28 2010
@@ -227,3 +227,10 @@
 
     def test_sign(self):
         assert format(-1.23, "1") == "-1.23"
+
+    def test_digit_separator(self):
+        assert format(-1234., "012,f") == "-1,234.000000"
+
+    def test_dont_switch_to_g(self):
+        skip("must fix when float formatting is figured out")
+        assert len(format(1.1234e90, "f")) == 98



More information about the Pypy-commit mailing list