[pypy-svn] pypy default: Fix a typo which truncated the output of format(1.23456789)

amauryfa commits-noreply at bitbucket.org
Tue Jan 25 18:01:07 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41321:55562a0f9c9d
Date: 2011-01-25 17:43 +0100
http://bitbucket.org/pypy/pypy/changeset/55562a0f9c9d/

Log:	Fix a typo which truncated the output of format(1.23456789)

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
@@ -781,7 +781,7 @@
         tp = self._type
         if tp == "\0":
             tp = "g"
-            default_prec = 12
+            default_precision = 12
             flags |= rarithmetic.DTSF_ADD_DOT_0
         elif tp == "n":
             tp = "g"

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
@@ -291,6 +291,15 @@
 
     def test_sign(self):
         assert format(-1.23, "1") == "-1.23"
+        x = 100.0 / 7.0
+        s = str(x)
+        assert format(x) == s
+        assert format(x, "-") == s
+        assert format(x, " ") == ' ' + s
+        assert format(x, "+") == '+' + s
+        assert format(-x, "-") == '-' + s
+        assert format(-x, " ") == '-' + s
+        assert format(-x, "+") == '-' + s
 
     def test_digit_separator(self):
         assert format(-1234., "012,f") == "-1,234.000000"


More information about the Pypy-commit mailing list