[pypy-commit] pypy stdlib-2.7.6: precision limit is actually INT_MAX

bdkearns noreply at buildbot.pypy.org
Sun Mar 2 03:28:35 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.6
Changeset: r69594:64b7e6ad4753
Date: 2014-03-01 21:27 -0500
http://bitbucket.org/pypy/pypy/changeset/64b7e6ad4753/

Log:	precision limit is actually INT_MAX

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
@@ -4,7 +4,6 @@
 import sys
 from pypy.interpreter.error import OperationError, oefmt
 from rpython.rlib import jit
-from rpython.rlib.rarithmetic import ovfcheck
 from rpython.rlib.rfloat import formatd, DTSF_ALT, isnan, isinf
 from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
 from rpython.rlib.unroll import unrolling_iterable
@@ -226,7 +225,7 @@
 
             if self.peekchr() == '.':
                 self.forward()
-                self.prec = self.peel_num('prec', sys.maxint)
+                self.prec = self.peel_num('prec', 2**31 - 1)
                 if self.prec < 0:
                     self.prec = 0    # this can happen:  '%.*f' % (-5, 3)
             else:
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
@@ -205,8 +205,7 @@
         assert "%x" % IntFails() == '0'
 
     def test_formatting_huge_precision(self):
-        import sys
-        format_string = "%.{}f".format(sys.maxint + 1)
+        format_string = "%.{}f".format(2**31)
         exc = raises(ValueError, "format_string % 2.34")
         assert exc.value[0] == 'prec too big'
 
@@ -337,8 +336,7 @@
         raises(ValueError, 'u"%\u1234" % (f,)')
 
     def test_formatting_huge_precision(self):
-        import sys
-        format_string = u"%.{}f".format(sys.maxint + 1)
+        format_string = u"%.{}f".format(2**31)
         exc = raises(ValueError, "format_string % 2.34")
         assert exc.value[0] == 'prec too big'
 


More information about the pypy-commit mailing list