diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 10:20:50 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 10:20:50 (GMT) |
commit | 99e2e5552ab6a105b188273658784963bb9a915c (patch) | |
tree | a5be0d6455e3f0eec37595061463ca7cda5aa29f /Lib/test/string_tests.py | |
parent | 10ba07a39eadaedd74e291f9d8b6b7f5e5c8702f (diff) | |
download | cpython-99e2e5552ab6a105b188273658784963bb9a915c.zip cpython-99e2e5552ab6a105b188273658784963bb9a915c.tar.gz cpython-99e2e5552ab6a105b188273658784963bb9a915c.tar.bz2 |
Issue #14700: Fix two broken and undefined-behaviour-inducing overflow checks in old-style string formatting. Thanks Serhiy Storchaka for report and original patch.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r-- | Lib/test/string_tests.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index b7246eb..eeeb457 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -1197,6 +1197,10 @@ class MixinStrUnicodeUserStringTest: self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) self.checkraises(ValueError, '%10', '__mod__', (42,)) + # Outrageously large width or precision should raise ValueError. + self.checkraises(ValueError, '%%%df' % (2**64), '__mod__', (3.2)) + self.checkraises(ValueError, '%%.%df' % (2**64), '__mod__', (3.2)) + def test_floatformatting(self): # float formatting for prec in range(100): |