[Python-checkins] cpython (2.7): Ensure that width and precision in string formatting test have type int, not

serhiy.storchaka python-checkins at python.org
Sat Jan 19 20:10:29 CET 2013


http://hg.python.org/cpython/rev/a78ebf9aed06
changeset:   81601:a78ebf9aed06
branch:      2.7
parent:      81595:b17d4d163862
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Jan 19 21:06:35 2013 +0200
summary:
  Ensure that width and precision in string formatting test have type int, not long.
Fix a regression from changeset d544873d62e9 (issue #15989).

files:
  Lib/test/string_tests.py |  24 ++++++++++++------------
  1 files changed, 12 insertions(+), 12 deletions(-)


diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1114,19 +1114,19 @@
         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())

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list