diff options
author | Georg Brandl <georg@python.org> | 2007-07-12 08:38:00 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-07-12 08:38:00 (GMT) |
commit | 7c3b50db6614c677588096191d432e734257a244 (patch) | |
tree | 4cb3d1c23d831f1ed5267210be2164317043fce2 /Lib/test | |
parent | bc5fbd9f8c1a271557846d7aa7a428ae25f901e8 (diff) | |
download | cpython-7c3b50db6614c677588096191d432e734257a244.zip cpython-7c3b50db6614c677588096191d432e734257a244.tar.gz cpython-7c3b50db6614c677588096191d432e734257a244.tar.bz2 |
Patch #1673759: add a missing overflow check when formatting floats
with %G.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_format.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 61e44f9..c4cfa11 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -9,6 +9,7 @@ maxsize = MAX_Py_ssize_t # test on unicode strings as well overflowok = 1 +overflowrequired = 0 def testformat(formatstr, args, output=None): if verbose: @@ -25,11 +26,16 @@ def testformat(formatstr, args, output=None): if verbose: print 'overflow (this is fine)' else: - if output and result != output: + if overflowrequired: if verbose: print 'no' - print "%s %% %s == %s != %s" %\ - (repr(formatstr), repr(args), repr(result), repr(output)) + print "overflow expected on %s %% %s" % \ + (repr(formatstr), repr(args)) + elif output and result != output: + if verbose: + print 'no' + print "%s %% %s == %s != %s" % \ + (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes' @@ -57,6 +63,14 @@ testboth("%#.*g", (110, -1.e+100/3.)) # test some ridiculously large precision, expect overflow testboth('%12.*f', (123456, 1.0)) +# check for internal overflow validation on length of precision +overflowrequired = 1 +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 testboth("%x", 10L, "a") |