Commits

Philip Jenvey committed 27567bc

redo the 'reset to g' from 52765baaf1aa so it actually works this time

Comments (0)

Files changed (2)

pypy/objspace/std/newformat.py

                 add_pct = False
             if self._precision == -1:
                 self._precision = default_precision
+            elif tp == "r":
+                tp = "g"
             result, special = rfloat.double_to_string(value, tp,
                                                       self._precision, flags)
             if add_pct:

pypy/objspace/std/test/test_floatobject.py

     def test_format(self):
         f = 1.1234e200
         assert f.__format__("G") == "1.1234E+200"
+        assert 123.456.__format__('.4') == '123.5'
+        assert 1234.56.__format__('.4') == '1.235e+03'
+        assert 12345.6.__format__('.4') == '1.235e+04'
 
     def test_float_real(self):
         class A(float): pass