summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-02-07 13:01:56 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-02-07 13:01:56 (GMT)
commit4dcba975900d21a84c14bf0cbc7c167839fcef9d (patch)
tree376e9580fcc7c720528a9e95c10e1bf87027a88c /Lib
parent64e8b970f9e7364ae62bd726cea6d6d7c60ecb34 (diff)
downloadcpython-4dcba975900d21a84c14bf0cbc7c167839fcef9d.zip
cpython-4dcba975900d21a84c14bf0cbc7c167839fcef9d.tar.gz
cpython-4dcba975900d21a84c14bf0cbc7c167839fcef9d.tar.bz2
Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_format.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 06179de..1ab4ea4 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -11,10 +11,11 @@ maxsize = test_support.MAX_Py_ssize_t
# test on unicode strings as well
overflowok = 1
-overflowrequired = 0
def testformat(formatstr, args, output=None, limit=None):
+ global overflowok
+
if verbose:
if output:
print "%s %% %s =? %s ..." %\
@@ -29,12 +30,7 @@ def testformat(formatstr, args, output=None, limit=None):
if verbose:
print 'overflow (this is fine)'
else:
- if overflowrequired:
- if verbose:
- print 'no'
- print "overflow expected on %s %% %s" % \
- (repr(formatstr), repr(args))
- elif output and limit is None and result != output:
+ if output and limit is None and result != output:
if verbose:
print 'no'
print "%s %% %s == %s != %s" % \
@@ -63,6 +59,8 @@ def testboth(formatstr, *args):
class FormatTest(unittest.TestCase):
def test_format(self):
+ global overflowok
+
testboth("%.1d", (1,), "1")
testboth("%.*d", (sys.maxint,1)) # expect overflow
testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
@@ -81,12 +79,12 @@ class FormatTest(unittest.TestCase):
testboth('%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.
testboth("%#.*g", (110, -1.e+100/3.))
testboth("%#.*G", (110, -1.e+100/3.))
testboth("%#.*f", (110, -1.e+100/3.))
testboth("%#.*F", (110, -1.e+100/3.))
- overflowrequired = 0
# Formatting of long integers. Overflow is not ok
overflowok = 0