mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed.
This commit is contained in:
parent
64e8b970f9
commit
4dcba97590
1 changed files with 7 additions and 9 deletions
|
|
@ -11,10 +11,11 @@ maxsize = test_support.MAX_Py_ssize_t
|
||||||
# test on unicode strings as well
|
# test on unicode strings as well
|
||||||
|
|
||||||
overflowok = 1
|
overflowok = 1
|
||||||
overflowrequired = 0
|
|
||||||
|
|
||||||
|
|
||||||
def testformat(formatstr, args, output=None, limit=None):
|
def testformat(formatstr, args, output=None, limit=None):
|
||||||
|
global overflowok
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
if output:
|
if output:
|
||||||
print "%s %% %s =? %s ..." %\
|
print "%s %% %s =? %s ..." %\
|
||||||
|
|
@ -29,12 +30,7 @@ def testformat(formatstr, args, output=None, limit=None):
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'overflow (this is fine)'
|
print 'overflow (this is fine)'
|
||||||
else:
|
else:
|
||||||
if overflowrequired:
|
if output and limit is None and result != output:
|
||||||
if verbose:
|
|
||||||
print 'no'
|
|
||||||
print "overflow expected on %s %% %s" % \
|
|
||||||
(repr(formatstr), repr(args))
|
|
||||||
elif output and limit is None and result != output:
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print 'no'
|
print 'no'
|
||||||
print "%s %% %s == %s != %s" % \
|
print "%s %% %s == %s != %s" % \
|
||||||
|
|
@ -63,6 +59,8 @@ def testboth(formatstr, *args):
|
||||||
|
|
||||||
class FormatTest(unittest.TestCase):
|
class FormatTest(unittest.TestCase):
|
||||||
def test_format(self):
|
def test_format(self):
|
||||||
|
global overflowok
|
||||||
|
|
||||||
testboth("%.1d", (1,), "1")
|
testboth("%.1d", (1,), "1")
|
||||||
testboth("%.*d", (sys.maxint,1)) # expect overflow
|
testboth("%.*d", (sys.maxint,1)) # expect overflow
|
||||||
testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
|
testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
|
||||||
|
|
@ -81,12 +79,12 @@ class FormatTest(unittest.TestCase):
|
||||||
testboth('%12.*f', (123456, 1.0))
|
testboth('%12.*f', (123456, 1.0))
|
||||||
|
|
||||||
# check for internal overflow validation on length of precision
|
# 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("%#.*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.))
|
||||||
testboth("%#.*F", (110, -1.e+100/3.))
|
testboth("%#.*F", (110, -1.e+100/3.))
|
||||||
overflowrequired = 0
|
|
||||||
|
|
||||||
# Formatting of long integers. Overflow is not ok
|
# Formatting of long integers. Overflow is not ok
|
||||||
overflowok = 0
|
overflowok = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue