summaryrefslogtreecommitdiff
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-01-19 21:06:35 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-01-19 21:06:35 +0200
commit18a13933f94e0d46d95f1c56c8e132b12044598e (patch)
tree6d40cbf65c8cf52f1a9278411e64724e9373554b /Lib/test/string_tests.py
parent302ad8d126b4be73071c47584a3123d1514e5921 (diff)
downloadcpython-git-18a13933f94e0d46d95f1c56c8e132b12044598e.tar.gz
Ensure that width and precision in string formatting test have type int, not long.
Fix a regression from changeset d544873d62e9 (issue #15989).
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index f73d0ee188..d3412d0cdc 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1114,19 +1114,19 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
self.checkraises(ValueError, '%10', '__mod__', (42,))
- if _testcapi.PY_SSIZE_T_MAX < sys.maxint:
- self.checkraises(OverflowError, '%*s', '__mod__',
- (_testcapi.PY_SSIZE_T_MAX + 1, ''))
- if _testcapi.INT_MAX < sys.maxint:
- self.checkraises(OverflowError, '%.*f', '__mod__',
- (_testcapi.INT_MAX + 1, 1. / 7))
+ width = int(_testcapi.PY_SSIZE_T_MAX + 1)
+ if width <= sys.maxint:
+ self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
+ prec = int(_testcapi.INT_MAX + 1)
+ if prec <= sys.maxint:
+ self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
# Issue 15989
- if 1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1) <= sys.maxint:
- self.checkraises(OverflowError, '%*s', '__mod__',
- (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1), ''))
- if _testcapi.UINT_MAX < sys.maxint:
- self.checkraises(OverflowError, '%.*f', '__mod__',
- (_testcapi.UINT_MAX + 1, 1. / 7))
+ width = int(1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1))
+ if width <= sys.maxint:
+ self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
+ prec = int(_testcapi.UINT_MAX + 1)
+ if prec <= sys.maxint:
+ self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
class X(object): pass
self.checkraises(TypeError, 'abc', '__mod__', X())