]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 78082,78086 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Sun, 7 Feb 2010 13:15:37 +0000 (13:15 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 7 Feb 2010 13:15:37 +0000 (13:15 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78082 | mark.dickinson | 2010-02-07 13:01:56 +0000 (Sun, 07 Feb 2010) | 1 line

  Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed.
........
  r78086 | mark.dickinson | 2010-02-07 13:09:52 +0000 (Sun, 07 Feb 2010) | 1 line

  Actually raise on failure, instead of doing nothing.
........

Lib/test/test_format.py

index 054baf612d223626533293c90c698ce1ba8c071b..88eb61a18f1f22317c15aaef301d492446dc1699 100644 (file)
@@ -11,7 +11,6 @@ maxsize = support.MAX_Py_ssize_t
 # test on unicode strings as well
 
 overflowok = 1
-overflowrequired = 0
 
 def testformat(formatstr, args, output=None, limit=None):
     if verbose:
@@ -28,15 +27,9 @@ def testformat(formatstr, args, output=None, limit=None):
         if verbose:
             print('overflow (this is fine)')
     else:
-        if overflowrequired:
+        if output and limit is None and result != output:
             if verbose:
                 print('no')
-            print("overflow expected on %r %% %r" % (formatstr, args))
-        elif output and limit is None and result != output:
-            if verbose:
-                print('no')
-            #print("%r %% %r == %r != %r" %\
-            #    (formatstr, args, result, output))
             raise AssertionError("%r %% %r == %r != %r" %
                                 (formatstr, args, result, output))
         # when 'limit' is specified, it determines how many characters
@@ -57,6 +50,8 @@ def testformat(formatstr, args, output=None, limit=None):
 
 class FormatTest(unittest.TestCase):
     def test_format(self):
+        global overflowok
+
         testformat("%.1d", (1,), "1")
         testformat("%.*d", (sys.maxsize,1))  # expect overflow
         testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
@@ -72,13 +67,14 @@ class FormatTest(unittest.TestCase):
         testformat("%#.*g", (110, -1.e+100/3.))
         # test some ridiculously large precision, expect overflow
         testformat('%12.*f', (123456, 1.0))
+
         # check for internal overflow validation on length of precision
-        overflowrequired = 1
+        # these tests should no longer cause overflow in Python
+        # 2.7/3.1 and later.
         testformat("%#.*g", (110, -1.e+100/3.))
         testformat("%#.*G", (110, -1.e+100/3.))
         testformat("%#.*f", (110, -1.e+100/3.))
         testformat("%#.*F", (110, -1.e+100/3.))
-        overflowrequired = 0
         # Formatting of integers. Overflow is not ok
         overflowok = 0
         testformat("%x", 10, "a")