summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-05-07 10:20:50 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-05-07 10:20:50 (GMT)
commit99e2e5552ab6a105b188273658784963bb9a915c (patch)
treea5be0d6455e3f0eec37595061463ca7cda5aa29f /Lib
parent10ba07a39eadaedd74e291f9d8b6b7f5e5c8702f (diff)
downloadcpython-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')
-rw-r--r--Lib/test/string_tests.py4
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):