]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Removed PyInt_GetMax and sys.maxint
authorChristian Heimes <christian@cheimes.de>
Tue, 4 Dec 2007 23:02:19 +0000 (23:02 +0000)
committerChristian Heimes <christian@cheimes.de>
Tue, 4 Dec 2007 23:02:19 +0000 (23:02 +0000)
I replaced sys.maxint with sys.maxsize in Lib/*.py. Does anybody see a problem with the change on Win 64bit platforms? Win 64's long is just 32bit but the sys.maxsize is now 2**63-1 on every 64bit platform.
Also added docs for sys.maxsize.

47 files changed:
Doc/library/itertools.rst
Doc/library/sys.rst
Include/longobject.h
Lib/UserString.py
Lib/_abcoll.py
Lib/ctypes/__init__.py
Lib/ctypes/util.py
Lib/email/generator.py
Lib/gzip.py
Lib/inspect.py
Lib/mhlib.py
Lib/sre_parse.py
Lib/subprocess.py
Lib/test/buffer_tests.py
Lib/test/list_tests.py
Lib/test/pickletester.py
Lib/test/regrtest.py
Lib/test/string_tests.py
Lib/test/test_builtin.py
Lib/test/test_bytes.py
Lib/test/test_compile.py
Lib/test/test_descr.py
Lib/test/test_format.py
Lib/test/test_grammar.py
Lib/test/test_hexoct.py
Lib/test/test_index.py
Lib/test/test_itertools.py
Lib/test/test_list.py
Lib/test/test_long.py
Lib/test/test_marshal.py
Lib/test/test_multibytecodec.py
Lib/test/test_multibytecodec_support.py
Lib/test/test_range.py
Lib/test/test_slice.py
Lib/test/test_struct.py
Lib/test/test_sys.py
Lib/test/test_threading.py
Lib/test/test_types.py
Lib/test/test_unicode.py
Lib/test/test_xmlrpc.py
Lib/zipfile.py
Misc/NEWS
Objects/longobject.c
Python/sysmodule.c
Tools/scripts/h2py.py
Tools/unicode/makeunicodedata.py
setup.py

index 7c7442b62b85a2dabb3b1914f963b715e6b190a2..54b52e470aba4edfa3831139f410f025feb050a0 100644 (file)
@@ -235,7 +235,7 @@ loops that truncate the stream.
 
       def islice(iterable, *args):
           s = slice(*args)
-          it = iter(range(s.start or 0, s.stop or sys.maxint, s.step or 1))
+          it = iter(range(s.start or 0, s.stop or sys.maxsize, s.step or 1))
           nexti = next(it)
           for i, element in enumerate(iterable):
               if i == nexti:
index 97f94aa05aa093cf68903f52dd712fd6f370d33e..3fc86e4df24072b07d486e5182b4c5dd30b3ff7a 100644 (file)
@@ -365,11 +365,12 @@ always available.
    etc.)
 
 
-.. data:: maxint
+.. data:: maxsize
 
-   The largest positive integer supported by Python's regular integer type.  This
-   is at least 2\*\*31-1.  The largest negative integer is ``-maxint-1`` --- the
-   asymmetry results from the use of 2's complement binary arithmetic.
+   An integer giving the size of ``Py_ssize_t``. It's usually 2**31-1 on a 32
+   bit platform and 2**63-1 on a 64bit platform.
+
+   ..versionadded:: 3.0
 
 
 .. data:: maxunicode
index e1ee5eead9e32f62e70b2f3f1826933f600918f7..d48552c9c1c273dd37e5e84ad6fc06339485835c 100644 (file)
@@ -31,8 +31,6 @@ PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
    cleanup to keep the extra information. [CH] */
 #define PyLong_AS_LONG(op) PyLong_AsLong(op)
 
-PyAPI_FUNC(long) PyInt_GetMax(void);
-
 /* Used by socketmodule.c */
 #if SIZEOF_SOCKET_T <= SIZEOF_LONG
 #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
index a11717c68e4a9db74bd3324a4c0f92fc83a8dc30..a8b805f6bc07ef35bef1d6d7df4750f17081e5d4 100755 (executable)
@@ -85,7 +85,7 @@ class UserString:
     def capitalize(self): return self.__class__(self.data.capitalize())
     def center(self, width, *args):
         return self.__class__(self.data.center(width, *args))
-    def count(self, sub, start=0, end=sys.maxint):
+    def count(self, sub, start=0, end=sys.maxsize):
         if isinstance(sub, UserString):
             sub = sub.data
         return self.data.count(sub, start, end)
@@ -105,15 +105,15 @@ class UserString:
                 return self.__class__(self.data.encode(encoding))
         else:
             return self.__class__(self.data.encode())
-    def endswith(self, suffix, start=0, end=sys.maxint):
+    def endswith(self, suffix, start=0, end=sys.maxsize):
         return self.data.endswith(suffix, start, end)
     def expandtabs(self, tabsize=8):
         return self.__class__(self.data.expandtabs(tabsize))
-    def find(self, sub, start=0, end=sys.maxint):
+    def find(self, sub, start=0, end=sys.maxsize):
         if isinstance(sub, UserString):
             sub = sub.data
         return self.data.find(sub, start, end)
-    def index(self, sub, start=0, end=sys.maxint):
+    def index(self, sub, start=0, end=sys.maxsize):
         return self.data.index(sub, start, end)
     def isalpha(self): return self.data.isalpha()
     def isalnum(self): return self.data.isalnum()
@@ -137,9 +137,9 @@ class UserString:
         if isinstance(new, UserString):
             new = new.data
         return self.__class__(self.data.replace(old, new, maxsplit))
-    def rfind(self, sub, start=0, end=sys.maxint):
+    def rfind(self, sub, start=0, end=sys.maxsize):
         return self.data.rfind(sub, start, end)
-    def rindex(self, sub, start=0, end=sys.maxint):
+    def rindex(self, sub, start=0, end=sys.maxsize):
         return self.data.rindex(sub, start, end)
     def rjust(self, width, *args):
         return self.__class__(self.data.rjust(width, *args))
@@ -151,7 +151,7 @@ class UserString:
     def rsplit(self, sep=None, maxsplit=-1):
         return self.data.rsplit(sep, maxsplit)
     def splitlines(self, keepends=0): return self.data.splitlines(keepends)
-    def startswith(self, prefix, start=0, end=sys.maxint):
+    def startswith(self, prefix, start=0, end=sys.maxsize):
         return self.data.startswith(prefix, start, end)
     def strip(self, chars=None): return self.__class__(self.data.strip(chars))
     def swapcase(self): return self.__class__(self.data.swapcase())
index 122aac085cbaba68846636661c3a80e35d76095a..36d39cf728eb6363693d657820b2d8e647e9ab42 100644 (file)
@@ -246,7 +246,7 @@ class Set(metaclass=ABCMeta):
         freedom for __eq__ or __hash__.  We match the algorithm used
         by the built-in frozenset type.
         """
-        MAX = sys.maxint
+        MAX = sys.maxsize
         MASK = 2 * MAX + 1
         n = len(self)
         h = 1927868237 * (n + 1)
index e1c9d84a0ac09235603d2108cf746b4cc3ced529..f7d0970f94bca8d82d3c347f023f0b6e11d763a9 100644 (file)
@@ -348,8 +348,8 @@ class CDLL(object):
     def __repr__(self):
         return "<%s '%s', handle %x at %x>" % \
                (self.__class__.__name__, self._name,
-                (self._handle & (_sys.maxint*2 + 1)),
-                id(self) & (_sys.maxint*2 + 1))
+                (self._handle & (_sys.maxsize*2 + 1)),
+                id(self) & (_sys.maxsize*2 + 1))
 
     def __getattr__(self, name):
         if name.startswith('__') and name.endswith('__'):
index f02b54774a28fc549dc2c9cb3b9b38a75d564d95..629e38315fb5f45ac215fb88d1853ce3e30fc38c 100644 (file)
@@ -98,7 +98,7 @@ elif os.name == "posix":
                     nums.insert(0, int(parts.pop()))
             except ValueError:
                 pass
-            return nums or [ sys.maxint ]
+            return nums or [ sys.maxsize ]
 
         def find_library(name):
             ename = re.escape(name)
index d46549cd882d28670f364df2b70ef4422990575c..ada14df95275ee4fca5b2a35100c69cf57ec8290 100644 (file)
@@ -307,13 +307,13 @@ class DecodedGenerator(Generator):
 
 \f
 # Helper
-_width = len(repr(sys.maxint-1))
+_width = len(repr(sys.maxsize-1))
 _fmt = '%%0%dd' % _width
 
 def _make_boundary(text=None):
     # Craft a random boundary.  If text is given, ensure that the chosen
     # boundary doesn't appear in the text.
-    token = random.randrange(sys.maxint)
+    token = random.randrange(sys.maxsize)
     boundary = ('=' * 15) + (_fmt % token) + '=='
     if text is None:
         return boundary
index a04408784edcb49950622ec42097fbe5ffcc9621..917c3f5279f33e731dd36dd1d041c6a48726d7ab 100644 (file)
@@ -409,7 +409,7 @@ class GzipFile:
 
     def readline(self, size=-1):
         if size < 0:
-            size = sys.maxint
+            size = sys.maxsize
             readsize = self.min_readsize
         else:
             readsize = size
@@ -441,7 +441,7 @@ class GzipFile:
     def readlines(self, sizehint=0):
         # Negative numbers result in reading all the lines
         if sizehint <= 0:
-            sizehint = sys.maxint
+            sizehint = sys.maxsize
         L = []
         while sizehint > 0:
             line = self.readline()
index 994dbdc51b4d4e61730b2fb1c5e80b10b9268d80..c0db4bc193463fec57febf15ef717c5820a77c38 100644 (file)
@@ -320,7 +320,7 @@ def getdoc(object):
         return None
     else:
         # Find minimum indentation of any non-blank lines after first line.
-        margin = sys.maxint
+        margin = sys.maxsize
         for line in lines[1:]:
             content = len(line.lstrip())
             if content:
@@ -329,7 +329,7 @@ def getdoc(object):
         # Remove indentation.
         if lines:
             lines[0] = lines[0].lstrip()
-        if margin < sys.maxint:
+        if margin < sys.maxsize:
             for i in range(1, len(lines)): lines[i] = lines[i][margin:]
         # Remove any trailing or leading blank lines.
         while lines and not lines[-1]:
index 955862b008e5885be381dfa8e9bf48e96a8e8b98..b42843944f262942a40e6af9f5622572b52aa905 100644 (file)
@@ -365,7 +365,7 @@ class Folder:
             try:
                 count = int(tail)
             except (ValueError, OverflowError):
-                # Can't use sys.maxint because of i+count below
+                # Can't use sys.maxsize because of i+count below
                 count = len(all)
             try:
                 anchor = self._parseindex(head, all)
@@ -428,7 +428,7 @@ class Folder:
             try:
                 return int(seq)
             except (OverflowError, ValueError):
-                return sys.maxint
+                return sys.maxsize
         if seq in ('cur', '.'):
             return self.getcurrent()
         if seq == 'first':
index fa0b8aaf82762869993e52d6f31276c4055793e7..a04c3432a6d528397b2c70854783e0e5bdf6fefc 100644 (file)
@@ -152,7 +152,7 @@ class SubPattern:
         REPEATCODES = (MIN_REPEAT, MAX_REPEAT)
         for op, av in self.data:
             if op is BRANCH:
-                i = sys.maxint
+                i = sys.maxsize
                 j = 0
                 for av in av[1]:
                     l, h = av.getwidth()
@@ -177,7 +177,7 @@ class SubPattern:
                 hi = hi + 1
             elif op == SUCCESS:
                 break
-        self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint))
+        self.width = int(min(lo, sys.maxsize)), int(min(hi, sys.maxsize))
         return self.width
 
 class Tokenizer:
index d134c3a45e1c093e620ab5bb4836649dfce69ed9..56e05a3774392c7661b599be46df23c6e3a1203a 100644 (file)
@@ -344,7 +344,7 @@ _active = []
 
 def _cleanup():
     for inst in _active[:]:
-        res = inst.poll(_deadstate=sys.maxint)
+        res = inst.poll(_deadstate=sys.maxsize)
         if res is not None and res >= 0:
             try:
                 _active.remove(inst)
@@ -562,7 +562,7 @@ class Popen(object):
             # We didn't get to successfully create a child process.
             return
         # In case the child hasn't been waited on, check if it's done.
-        self.poll(_deadstate=sys.maxint)
+        self.poll(_deadstate=sys.maxsize)
         if self.returncode is None and _active is not None:
             # Child is still running, keep us alive until we can wait on it.
             _active.append(self)
index db27759d795c5814c79db150e690046d714b8bb5..8696eab61da0a0b4156a3f8659c01b073c96f845 100644 (file)
@@ -172,9 +172,9 @@ class MixinBytesBufferCommonTests(object):
 
         self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42)
         # This test is only valid when sizeof(int) == sizeof(void*) == 4.
-        if sys.maxint < (1 << 32) and struct.calcsize('P') == 4:
+        if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
             self.assertRaises(OverflowError,
-                              self.marshal(b'\ta\n\tb').expandtabs, sys.maxint)
+                              self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize)
 
     def test_title(self):
         self.assertEqual(b' Hello ', self.marshal(b' hello ').title())
index 2c961cef2f407b65ecd881f6dab5a188b5ffbbac..43173165edb02e3b9e7900cac7a119af1e5b14d1 100644 (file)
@@ -388,8 +388,8 @@ class CommonTest(seq_tests.CommonTest):
         self.assertEqual(a.index(0, -3), 3)
         self.assertEqual(a.index(0, 3, 4), 3)
         self.assertEqual(a.index(0, -3, -2), 3)
-        self.assertEqual(a.index(0, -4*sys.maxint, 4*sys.maxint), 2)
-        self.assertRaises(ValueError, a.index, 0, 4*sys.maxint,-4*sys.maxint)
+        self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2)
+        self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize)
         self.assertRaises(ValueError, a.index, 2, 0, -10)
         a.remove(0)
         self.assertRaises(ValueError, a.index, 2, 0, 4)
index b20f599294b890da808b31e2bd66411da5cea71c..5ac2bdcfc3a0e1cc789b7d342062f2b0f10195e4 100644 (file)
@@ -493,7 +493,7 @@ class AbstractPickleTests(unittest.TestCase):
     def test_ints(self):
         import sys
         for proto in protocols:
-            n = sys.maxint
+            n = sys.maxsize
             while n:
                 for expected in (-n, n):
                     s = self.dumps(expected, proto)
index f4569abc072385cef994f61b62633a7090bb6379..16f4d3d930cd4b9ab9de843a4e7dc7e85367f1ed 100755 (executable)
@@ -140,7 +140,7 @@ import traceback
 # putting them in test_grammar.py has no effect:
 warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
                         ".*test.test_grammar$")
-if sys.maxint > 0x7fffffff:
+if sys.maxsize > 0x7fffffff:
     # Also suppress them in <string>, because for 64-bit platforms,
     # that's where test_grammar.py hides them.
     warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
index 909f94747291053d974ff86c5ae857e53ae49bda..80fe4758c4e4f9d0a559354516fd0070b1de3edb 100644 (file)
@@ -265,9 +265,9 @@ class BaseTest(unittest.TestCase):
 
         self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
         # This test is only valid when sizeof(int) == sizeof(void*) == 4.
-        if sys.maxint < (1 << 32) and struct.calcsize('P') == 4:
+        if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
             self.checkraises(OverflowError,
-                             '\ta\n\tb', 'expandtabs', sys.maxint)
+                             '\ta\n\tb', 'expandtabs', sys.maxsize)
 
     def test_split(self):
         # by a char
@@ -278,7 +278,7 @@ class BaseTest(unittest.TestCase):
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|',
-                        sys.maxint-2)
+                        sys.maxsize-2)
         self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0)
         self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2)
         self.checkequal(['endcase ', ''], 'endcase |', 'split', '|')
@@ -297,7 +297,7 @@ class BaseTest(unittest.TestCase):
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//',
-                        sys.maxint-10)
+                        sys.maxsize-10)
         self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0)
         self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2)
         self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test')
@@ -334,7 +334,7 @@ class BaseTest(unittest.TestCase):
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|',
-                        sys.maxint-100)
+                        sys.maxsize-100)
         self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0)
         self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2)
         self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|')
@@ -354,7 +354,7 @@ class BaseTest(unittest.TestCase):
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//',
-                        sys.maxint-5)
+                        sys.maxsize-5)
         self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0)
         self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2)
         self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test')
@@ -392,7 +392,7 @@ class BaseTest(unittest.TestCase):
         EQ("", "", "replace", "A", "")
         EQ("", "", "replace", "A", "A")
         EQ("", "", "replace", "", "", 100)
-        EQ("", "", "replace", "", "", sys.maxint)
+        EQ("", "", "replace", "", "", sys.maxsize)
 
         # interleave (from=="", 'to' gets inserted everywhere)
         EQ("A", "A", "replace", "", "")
@@ -401,7 +401,7 @@ class BaseTest(unittest.TestCase):
         EQ("*-#A*-#", "A", "replace", "", "*-#")
         EQ("*-A*-A*-", "AA", "replace", "", "*-")
         EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
-        EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint)
+        EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize)
         EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
         EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
         EQ("*-A*-A", "AA", "replace", "", "*-", 2)
@@ -412,7 +412,7 @@ class BaseTest(unittest.TestCase):
         EQ("", "A", "replace", "A", "")
         EQ("", "AAA", "replace", "A", "")
         EQ("", "AAA", "replace", "A", "", -1)
-        EQ("", "AAA", "replace", "A", "", sys.maxint)
+        EQ("", "AAA", "replace", "A", "", sys.maxsize)
         EQ("", "AAA", "replace", "A", "", 4)
         EQ("", "AAA", "replace", "A", "", 3)
         EQ("A", "AAA", "replace", "A", "", 2)
@@ -421,7 +421,7 @@ class BaseTest(unittest.TestCase):
         EQ("", "AAAAAAAAAA", "replace", "A", "")
         EQ("BCD", "ABACADA", "replace", "A", "")
         EQ("BCD", "ABACADA", "replace", "A", "", -1)
-        EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint)
+        EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize)
         EQ("BCD", "ABACADA", "replace", "A", "", 5)
         EQ("BCD", "ABACADA", "replace", "A", "", 4)
         EQ("BCDA", "ABACADA", "replace", "A", "", 3)
@@ -444,7 +444,7 @@ class BaseTest(unittest.TestCase):
         EQ("thaet", "thaet", "replace", "the", "")
         EQ("here and re", "here and there", "replace", "the", "")
         EQ("here and re and re", "here and there and there",
-           "replace", "the", "", sys.maxint)
+           "replace", "the", "", sys.maxsize)
         EQ("here and re and re", "here and there and there",
            "replace", "the", "", -1)
         EQ("here and re and re", "here and there and there",
@@ -469,7 +469,7 @@ class BaseTest(unittest.TestCase):
         # single character replace in place (len(from)==len(to)==1)
         EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
-        EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint)
+        EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize)
         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
@@ -486,7 +486,7 @@ class BaseTest(unittest.TestCase):
 
         # substring replace in place (len(from)==len(to) > 1)
         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
-        EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint)
+        EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize)
         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
@@ -500,7 +500,7 @@ class BaseTest(unittest.TestCase):
         # replace single character (len(from)==1, len(to)>1)
         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
-        EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint)
+        EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize)
         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
         EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
         EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
@@ -512,7 +512,7 @@ class BaseTest(unittest.TestCase):
         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
            "replace", "spam", "ham")
         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
-           "replace", "spam", "ham", sys.maxint)
+           "replace", "spam", "ham", sys.maxsize)
         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
            "replace", "spam", "ham", -1)
         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
@@ -567,7 +567,7 @@ class BaseTest(unittest.TestCase):
 
     def test_replace_overflow(self):
         # Check for overflow checking on 32 bit machines
-        if sys.maxint != 2147483647 or struct.calcsize("P") > 4:
+        if sys.maxsize != 2147483647 or struct.calcsize("P") > 4:
             return
         A2_16 = "A" * (2**16)
         self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
@@ -631,7 +631,7 @@ class CommonTest(BaseTest):
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None,
-                        sys.maxint-1)
+                        sys.maxsize-1)
         self.checkequal(['a b c d'], 'a b c d', 'split', None, 0)
         self.checkequal(['a b c d'], '  a b c d', 'split', None, 0)
         self.checkequal(['a', 'b', 'c  d'], 'a  b  c  d', 'split', None, 2)
@@ -662,7 +662,7 @@ class CommonTest(BaseTest):
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3)
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4)
         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None,
-                        sys.maxint-20)
+                        sys.maxsize-20)
         self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0)
         self.checkequal(['a b c d'], 'a b c d  ', 'rsplit', None, 0)
         self.checkequal(['a  b', 'c', 'd'], 'a  b  c  d', 'rsplit', None, 2)
index d54375118de10f3a148ad7ff0700c9bd2507ee23..be6f391ba8f2866e9decf53e45c87bf0c0630dd7 100644 (file)
@@ -60,7 +60,7 @@ L = [
         (' 314', 314),
         ('314 ', 314),
         ('  \t\t  314  \t\t  ', 314),
-        (repr(sys.maxint), sys.maxint),
+        (repr(sys.maxsize), sys.maxsize),
         ('  1x', ValueError),
         ('  1  ', 1),
         ('  1\02  ', ValueError),
@@ -97,7 +97,7 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(abs(0), 0)
         self.assertEqual(abs(1234), 1234)
         self.assertEqual(abs(-1234), 1234)
-        self.assertTrue(abs(-sys.maxint-1) > 0)
+        self.assertTrue(abs(-sys.maxsize-1) > 0)
         # float
         self.assertEqual(abs(0.0), 0.0)
         self.assertEqual(abs(3.14), 3.14)
@@ -138,9 +138,9 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(any(x > 42 for x in S), False)
 
     def test_neg(self):
-        x = -sys.maxint-1
+        x = -sys.maxsize-1
         self.assert_(isinstance(x, int))
-        self.assertEqual(-x, sys.maxint+1)
+        self.assertEqual(-x, sys.maxsize+1)
 
     # XXX(nnorwitz): This test case for callable should probably be removed.
     def test_callable(self):
@@ -306,8 +306,8 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(divmod(12, -7), (-2, -2))
         self.assertEqual(divmod(-12, -7), (1, -5))
 
-        self.assertEqual(divmod(-sys.maxint-1, -1),
-                         (sys.maxint+1, 0))
+        self.assertEqual(divmod(-sys.maxsize-1, -1),
+                         (sys.maxsize+1, 0))
 
         self.assert_(not fcmp(divmod(3.25, 1.0), (3.0, 0.25)))
         self.assert_(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)))
@@ -644,12 +644,12 @@ class BuiltinTest(unittest.TestCase):
                     except v:
                         pass
 
-        s = repr(-1-sys.maxint)
+        s = repr(-1-sys.maxsize)
         x = int(s)
-        self.assertEqual(x+1, -sys.maxint)
+        self.assertEqual(x+1, -sys.maxsize)
         self.assert_(isinstance(x, int))
         # should return long
-        self.assertEqual(int(s[1:]), sys.maxint+1)
+        self.assertEqual(int(s[1:]), sys.maxsize+1)
 
         # should return long
         x = int(1e100)
@@ -661,7 +661,7 @@ class BuiltinTest(unittest.TestCase):
         # SF bug 434186:  0x80000000/2 != 0x80000000>>1.
         # Worked by accident in Windows release build, but failed in debug build.
         # Failed in all Linux builds.
-        x = -1-sys.maxint
+        x = -1-sys.maxsize
         self.assertEqual(x >> 1, x//2)
 
         self.assertRaises(ValueError, int, '123\0')
@@ -881,12 +881,12 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(list(''), [])
         self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
 
-        if sys.maxint == 0x7fffffff:
+        if sys.maxsize == 0x7fffffff:
             # This test can currently only work on 32-bit machines.
             # XXX If/when PySequence_Length() returns a ssize_t, it should be
             # XXX re-enabled.
             # Verify clearing of bug #556025.
-            # This assumes that the max data size (sys.maxint) == max
+            # This assumes that the max data size (sys.maxsize) == max
             # address size this also assumes that the address size is at
             # least 4 bytes with 8 byte addresses, the bug is not well
             # tested
@@ -896,7 +896,7 @@ class BuiltinTest(unittest.TestCase):
             # thread for the details:
 
             #     http://sources.redhat.com/ml/newlib/2002/msg00369.html
-            self.assertRaises(MemoryError, list, range(sys.maxint // 2))
+            self.assertRaises(MemoryError, list, range(sys.maxsize // 2))
 
         # This code used to segfault in Py2.4a3
         x = []
@@ -1384,9 +1384,9 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(list(range(0, 2**100, -1)), [])
         self.assertEqual(list(range(0, 2**100, -1)), [])
 
-        a = int(10 * sys.maxint)
-        b = int(100 * sys.maxint)
-        c = int(50 * sys.maxint)
+        a = int(10 * sys.maxsize)
+        b = int(100 * sys.maxsize)
+        c = int(50 * sys.maxsize)
 
         self.assertEqual(list(range(a, a+2)), [a, a+1])
         self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
@@ -1428,10 +1428,10 @@ class BuiltinTest(unittest.TestCase):
         self.assertRaises(TypeError, range, 0, "spam")
         self.assertRaises(TypeError, range, 0, 42, "spam")
 
-        #NEAL self.assertRaises(OverflowError, range, -sys.maxint, sys.maxint)
-        #NEAL self.assertRaises(OverflowError, range, 0, 2*sys.maxint)
+        #NEAL self.assertRaises(OverflowError, range, -sys.maxsize, sys.maxsize)
+        #NEAL self.assertRaises(OverflowError, range, 0, 2*sys.maxsize)
 
-        self.assertRaises(OverflowError, len, range(0, sys.maxint**10))
+        self.assertRaises(OverflowError, len, range(0, sys.maxsize**10))
 
     def test_input(self):
         self.write_testfile()
index f037d4ce71bfd064c53617f6364d68204cb22059..0fd2f76dd951e4fed65f03c7e94e56a5363ed52a 100644 (file)
@@ -36,14 +36,14 @@ class BytesTest(unittest.TestCase):
         self.assertEqual(len(b), 0)
         self.assertRaises(IndexError, lambda: b[0])
         self.assertRaises(IndexError, lambda: b[1])
-        self.assertRaises(IndexError, lambda: b[sys.maxint])
-        self.assertRaises(IndexError, lambda: b[sys.maxint+1])
+        self.assertRaises(IndexError, lambda: b[sys.maxsize])
+        self.assertRaises(IndexError, lambda: b[sys.maxsize+1])
         self.assertRaises(IndexError, lambda: b[10**100])
         self.assertRaises(IndexError, lambda: b[-1])
         self.assertRaises(IndexError, lambda: b[-2])
-        self.assertRaises(IndexError, lambda: b[-sys.maxint])
-        self.assertRaises(IndexError, lambda: b[-sys.maxint-1])
-        self.assertRaises(IndexError, lambda: b[-sys.maxint-2])
+        self.assertRaises(IndexError, lambda: b[-sys.maxsize])
+        self.assertRaises(IndexError, lambda: b[-sys.maxsize-1])
+        self.assertRaises(IndexError, lambda: b[-sys.maxsize-2])
         self.assertRaises(IndexError, lambda: b[-10**100])
 
     def test_from_list(self):
@@ -83,14 +83,14 @@ class BytesTest(unittest.TestCase):
 
     def test_constructor_value_errors(self):
         self.assertRaises(ValueError, bytearray, [-1])
-        self.assertRaises(ValueError, bytearray, [-sys.maxint])
-        self.assertRaises(ValueError, bytearray, [-sys.maxint-1])
-        self.assertRaises(ValueError, bytearray, [-sys.maxint-2])
+        self.assertRaises(ValueError, bytearray, [-sys.maxsize])
+        self.assertRaises(ValueError, bytearray, [-sys.maxsize-1])
+        self.assertRaises(ValueError, bytearray, [-sys.maxsize-2])
         self.assertRaises(ValueError, bytearray, [-10**100])
         self.assertRaises(ValueError, bytearray, [256])
         self.assertRaises(ValueError, bytearray, [257])
-        self.assertRaises(ValueError, bytearray, [sys.maxint])
-        self.assertRaises(ValueError, bytearray, [sys.maxint+1])
+        self.assertRaises(ValueError, bytearray, [sys.maxsize])
+        self.assertRaises(ValueError, bytearray, [sys.maxsize+1])
         self.assertRaises(ValueError, bytearray, [10**100])
 
     def test_repr_str(self):
@@ -412,7 +412,7 @@ class BytesTest(unittest.TestCase):
             self.assertRaises(TypeError, lambda: 3.14 * b)
             # XXX Shouldn't bytes and bytearray agree on what to raise?
             self.assertRaises((OverflowError, MemoryError),
-                              lambda: b * sys.maxint)
+                              lambda: b * sys.maxsize)
 
     def test_repeat_1char(self):
         self.assertEqual(b'x'*100, bytearray([ord('x')]*100))
index cc490d722fc4935aa9ddf98aaaf21448dd2c11f3..4979f9263c5618046004f84cbb25cfd32677981f 100644 (file)
@@ -194,24 +194,24 @@ if 1:
 
     def test_unary_minus(self):
         # Verify treatment of unary minus on negative numbers SF bug #660455
-        if sys.maxint == 2147483647:
+        if sys.maxsize == 2147483647:
             # 32-bit machine
             all_one_bits = '0xffffffff'
             self.assertEqual(eval(all_one_bits), 4294967295)
             self.assertEqual(eval("-" + all_one_bits), -4294967295)
-        elif sys.maxint == 9223372036854775807:
+        elif sys.maxsize == 9223372036854775807:
             # 64-bit machine
             all_one_bits = '0xffffffffffffffff'
             self.assertEqual(eval(all_one_bits), 18446744073709551615)
             self.assertEqual(eval("-" + all_one_bits), -18446744073709551615)
         else:
             self.fail("How many bits *does* this machine have???")
-        # Verify treatment of contant folding on -(sys.maxint+1)
+        # Verify treatment of contant folding on -(sys.maxsize+1)
         # i.e. -2147483648 on 32 bit platforms.  Should return int, not long.
-        self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 1)), int))
-        self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 2)), int))
+        self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 1)), int))
+        self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 2)), int))
 
-    if sys.maxint == 9223372036854775807:
+    if sys.maxsize == 9223372036854775807:
         def test_32_63_bit_values(self):
             a = +4294967296  # 1 << 32
             b = -4294967296  # 1 << 32
index aa01805a98fa04167f8adaa030f47b71122fdbe1..199a49ca166ac5cd96f8a28cd4a2a4ee3dadea84 100644 (file)
@@ -4118,8 +4118,8 @@ def notimplemented():
         else:
             raise TestFailed("no TypeError from %r" % (expr,))
 
-    N1 = sys.maxint + 1    # might trigger OverflowErrors instead of TypeErrors
-    N2 = sys.maxint         # if sizeof(int) < sizeof(long), might trigger
+    N1 = sys.maxsize + 1    # might trigger OverflowErrors instead of TypeErrors
+    N2 = sys.maxsize         # if sizeof(int) < sizeof(long), might trigger
                             #   ValueErrors instead of TypeErrors
     if 1:
         metaclass = type
index 0b02adf1ce92b51f7b7db548ca173e3558be75bf..9f4528c2c978764a4c651667d4ae8021cca04e73 100644 (file)
@@ -40,7 +40,7 @@ def testformat(formatstr, args, output=None):
                 print('yes')
 
 testformat("%.1d", (1,), "1")
-testformat("%.*d", (sys.maxint,1))  # expect overflow
+testformat("%.*d", (sys.maxsize,1))  # expect overflow
 testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
 testformat("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
 testformat("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
index ee3ffc7e2e0f8ed2457ce301e3148f3b6ca615f4..7ab755707c475e0a3f00f2fbc838231dd24771dc 100644 (file)
@@ -32,8 +32,8 @@ class TokenTests(unittest.TestCase):
         self.assertEquals(0o377, 255)
         self.assertEquals(2147483647, 0o17777777777)
         self.assertEquals(0b1001, 9)
-        from sys import maxint
-        if maxint == 2147483647:
+        from sys import maxsize
+        if maxsize == 2147483647:
             self.assertEquals(-2147483647-1, -0o20000000000)
             # XXX -2147483648
             self.assert_(0o37777777777 > 0)
@@ -45,7 +45,7 @@ class TokenTests(unittest.TestCase):
                     x = eval(s)
                 except OverflowError:
                     self.fail("OverflowError on huge integer literal %r" % s)
-        elif maxint == 9223372036854775807:
+        elif maxsize == 9223372036854775807:
             self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000)
             self.assert_(0o1777777777777777777777 > 0)
             self.assert_(0xffffffffffffffff > 0)
@@ -58,7 +58,7 @@ class TokenTests(unittest.TestCase):
                 except OverflowError:
                     self.fail("OverflowError on huge integer literal %r" % s)
         else:
-            self.fail('Weird maxint value %r' % maxint)
+            self.fail('Weird maxsize value %r' % maxsize)
 
     def testLongIntegers(self):
         x = 0
index afd696afc5634a7deef860902eee3f401b42042c..df9b310042cd3da328e698af3a35f4b4865f1d9f 100644 (file)
@@ -4,7 +4,7 @@ This is complex because of changes due to PEP 237.
 """
 
 import sys
-platform_long_is_32_bits = sys.maxint == 2147483647
+platform_long_is_32_bits = sys.maxsize == 2147483647
 
 import unittest
 from test import test_support
index 6275e1219cc8758306c88f85ffeb551c5223faf4..9a22020d9fa078f47d2b90deb1e604d054392828 100644 (file)
@@ -2,7 +2,6 @@ import unittest
 from test import test_support
 import operator
 import sys
-from sys import maxint
 maxsize = test_support.MAX_Py_ssize_t
 minsize = -maxsize-1
 
@@ -180,7 +179,7 @@ class OverflowTestCase(unittest.TestCase):
     def test_getitem(self):
         class GetItem(object):
             def __len__(self):
-                return maxint #cannot return long here
+                return sys.maxsize
             def __getitem__(self, key):
                 return key
         x = GetItem()
index 81e2e8eccdc8280eea6d5e9d688bbee466fb65d9..17e00585aa713ec60063288bf463ccd5544ca552 100644 (file)
@@ -71,7 +71,7 @@ class TestBasicOps(unittest.TestCase):
         self.assertEqual(repr(c), 'count(-9)')
         next(c)
         self.assertEqual(next(c), -8)
-        for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5):
+        for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5):
             # Test repr (ignoring the L in longs)
             r1 = repr(count(i)).replace('L', '')
             r2 = 'count(%r)'.__mod__(i).replace('L', '')
index 2afb3e9f0e3344788e05c8742386a2ae4296e700..5b84a42a76a72a5e16ed9e4203777a731beb7327 100644 (file)
@@ -21,7 +21,7 @@ class ListTest(list_tests.CommonTest):
 
     def test_overflow(self):
         lst = [4, 5, 6, 7]
-        n = int((sys.maxint*2+2) // len(lst))
+        n = int((sys.maxsize*2+2) // len(lst))
         def mul(a, b): return a * b
         def imul(a, b): a *= b
         self.assertRaises((MemoryError, OverflowError), mul, lst, n)
index bdda5d876838708a7b0be514333d627b5eda4504..8be8bff249a6253c13e329e6affa11a8f0159efc 100644 (file)
@@ -233,48 +233,48 @@ class LongTest(unittest.TestCase):
         import sys
 
         # check the extremes in int<->long conversion
-        hugepos = sys.maxint
+        hugepos = sys.maxsize
         hugeneg = -hugepos - 1
         hugepos_aslong = int(hugepos)
         hugeneg_aslong = int(hugeneg)
-        self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxint) != sys.maxint")
+        self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxsize) != sys.maxsize")
         self.assertEqual(hugeneg, hugeneg_aslong,
-            "long(-sys.maxint-1) != -sys.maxint-1")
+            "long(-sys.maxsize-1) != -sys.maxsize-1")
 
         # long -> int should not fail for hugepos_aslong or hugeneg_aslong
         x = int(hugepos_aslong)
         try:
             self.assertEqual(x, hugepos,
-                  "converting sys.maxint to long and back to int fails")
+                  "converting sys.maxsize to long and back to int fails")
         except OverflowError:
-            self.fail("int(long(sys.maxint)) overflowed!")
+            self.fail("int(long(sys.maxsize)) overflowed!")
         if not isinstance(x, int):
-            raise TestFailed("int(long(sys.maxint)) should have returned int")
+            raise TestFailed("int(long(sys.maxsize)) should have returned int")
         x = int(hugeneg_aslong)
         try:
             self.assertEqual(x, hugeneg,
-                  "converting -sys.maxint-1 to long and back to int fails")
+                  "converting -sys.maxsize-1 to long and back to int fails")
         except OverflowError:
-            self.fail("int(long(-sys.maxint-1)) overflowed!")
+            self.fail("int(long(-sys.maxsize-1)) overflowed!")
         if not isinstance(x, int):
-            raise TestFailed("int(long(-sys.maxint-1)) should have "
+            raise TestFailed("int(long(-sys.maxsize-1)) should have "
                              "returned int")
         # but long -> int should overflow for hugepos+1 and hugeneg-1
         x = hugepos_aslong + 1
         try:
             y = int(x)
         except OverflowError:
-            self.fail("int(long(sys.maxint) + 1) mustn't overflow")
+            self.fail("int(long(sys.maxsize) + 1) mustn't overflow")
         self.assert_(isinstance(y, int),
-            "int(long(sys.maxint) + 1) should have returned long")
+            "int(long(sys.maxsize) + 1) should have returned long")
 
         x = hugeneg_aslong - 1
         try:
             y = int(x)
         except OverflowError:
-            self.fail("int(long(-sys.maxint-1) - 1) mustn't overflow")
+            self.fail("int(long(-sys.maxsize-1) - 1) mustn't overflow")
         self.assert_(isinstance(y, int),
-               "int(long(-sys.maxint-1) - 1) should have returned long")
+               "int(long(-sys.maxsize-1) - 1) should have returned long")
 
         class long2(int):
             pass
@@ -288,8 +288,8 @@ class LongTest(unittest.TestCase):
     def test_auto_overflow(self):
         import math, sys
 
-        special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1]
-        sqrt = int(math.sqrt(sys.maxint))
+        special = [0, 1, 2, 3, sys.maxsize-1, sys.maxsize, sys.maxsize+1]
+        sqrt = int(math.sqrt(sys.maxsize))
         special.extend([sqrt-1, sqrt, sqrt+1])
         special.extend([-i for i in special])
 
@@ -462,7 +462,7 @@ class LongTest(unittest.TestCase):
         for t in 2.0**48, 2.0**50, 2.0**53:
             cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0,
                           int(t-1), int(t), int(t+1)])
-        cases.extend([0, 1, 2, sys.maxint, float(sys.maxint)])
+        cases.extend([0, 1, 2, sys.maxsize, float(sys.maxsize)])
         # 1L<<20000 should exceed all double formats.  long(1e200) is to
         # check that we get equality with 1e200 above.
         t = int(1e200)
index d14d50dca9daa0c7e1c06aa412122c6f379d5598..66545e0769191e1b3bb1c77b7817379adc0eafd3 100644 (file)
@@ -28,7 +28,7 @@ class HelperMixin:
 class IntTestCase(unittest.TestCase, HelperMixin):
     def test_ints(self):
         # Test the full range of Python ints.
-        n = sys.maxint
+        n = sys.maxsize
         while n:
             for expected in (-n, n):
                 self.helper(expected)
@@ -66,7 +66,7 @@ class FloatTestCase(unittest.TestCase, HelperMixin):
     def test_floats(self):
         # Test a few floats
         small = 1e-25
-        n = sys.maxint * 3.7e250
+        n = sys.maxsize * 3.7e250
         while n > small:
             for expected in (-n, n):
                 self.helper(float(expected))
@@ -81,7 +81,7 @@ class FloatTestCase(unittest.TestCase, HelperMixin):
         got = marshal.loads(s)
         self.assertEqual(f, got)
 
-        n = sys.maxint * 3.7e-250
+        n = sys.maxsize * 3.7e-250
         while n < small:
             for expected in (-n, n):
                 f = float(expected)
index e9d3ef0a8364ddf2324e1a23253137dad9a206f0..615ad8b05531eaa1c0ea133e579f870b2de6469d 100644 (file)
@@ -40,7 +40,7 @@ class Test_MultibyteCodec(unittest.TestCase):
 
     def test_errorcallback_longindex(self):
         dec = codecs.getdecoder('euc-kr')
-        myreplace  = lambda exc: ('', sys.maxint+1)
+        myreplace  = lambda exc: ('', sys.maxsize+1)
         codecs.register_error('test.cjktest', myreplace)
         self.assertRaises(IndexError, dec,
                           'apple\x92ham\x93spam', 'test.cjktest')
index 957b9fc9ec02ca5158630500e647a41f93955f7a..6b67057265088901481b86b0a8abc2274d8d5200 100644 (file)
@@ -114,7 +114,7 @@ class TestBase:
                                      'test.cjktest'), (b'abcdxefgh', 9))
 
         def myreplace(exc):
-            return ('x', sys.maxint + 1)
+            return ('x', sys.maxsize + 1)
         codecs.register_error("test.cjktest", myreplace)
         self.assertRaises(IndexError, self.encode, self.unmappedunicode,
                           'test.cjktest')
index 0a4c9a0600bea8fc5a72cae738897eb94b69532b..dedf007282c70972f209522dadb0ced54b617400 100644 (file)
@@ -51,10 +51,10 @@ class RangeTest(unittest.TestCase):
         self.assertRaises(TypeError, range, 0, "spam")
         self.assertRaises(TypeError, range, 0, 42, "spam")
 
-        self.assertEqual(len(range(0, sys.maxint, sys.maxint-1)), 2)
+        self.assertEqual(len(range(0, sys.maxsize, sys.maxsize-1)), 2)
 
-        r = range(-sys.maxint, sys.maxint, 2)
-        self.assertEqual(len(r), sys.maxint)
+        r = range(-sys.maxsize, sys.maxsize, 2)
+        self.assertEqual(len(r), sys.maxsize)
 
     def test_repr(self):
         self.assertEqual(repr(range(1)), 'range(0, 1)')
index cb9d8b240dd0425a5486099a0835a9f0c9034df6..20d2027028888a60f57a83cd7640edcbfdb057a7 100644 (file)
@@ -92,7 +92,7 @@ class SliceTest(unittest.TestCase):
         )
         self.assertEqual(slice(-100, 100, 2).indices(10), (0, 10,  2))
 
-        self.assertEqual(list(range(10))[::sys.maxint - 1], [0])
+        self.assertEqual(list(range(10))[::sys.maxsize - 1], [0])
 
         self.assertRaises(OverflowError, slice(None).indices, 1<<100)
 
index 34596e04ad3ba29aadee1014006535c7182a6fdd..23358be383b13c72d4f94e4b404fc14ee9bbfedf 100644 (file)
@@ -506,8 +506,8 @@ def test_1229380():
         deprecated_err(struct.pack, endian + 'B', 300)
         deprecated_err(struct.pack, endian + 'H', 70000)
 
-        deprecated_err(struct.pack, endian + 'I', sys.maxint * 4)
-        deprecated_err(struct.pack, endian + 'L', sys.maxint * 4)
+        deprecated_err(struct.pack, endian + 'I', sys.maxsize * 4)
+        deprecated_err(struct.pack, endian + 'L', sys.maxsize * 4)
 
 if PY_STRUCT_RANGE_CHECKING:
     test_1229380()
index 435a6968cbeb02220fcec27c0f618f52aa9f27f8..0a62c01c220b6f7a56c378646d4544bc0f830867 100644 (file)
@@ -282,7 +282,7 @@ class SysModuleTest(unittest.TestCase):
         self.assert_(isinstance(sys.float_info, dict))
         self.assertEqual(len(sys.float_info), 11)
         self.assert_(isinstance(sys.hexversion, int))
-        self.assert_(isinstance(sys.maxint, int))
+        self.assert_(isinstance(sys.maxsize, int))
         self.assert_(isinstance(sys.maxunicode, int))
         self.assert_(isinstance(sys.platform, str))
         self.assert_(isinstance(sys.prefix, str))
index e5ed201b0afe679db3972fe987088a14ed6a9b71..5dd3aea72b1460d42891cdd4d086a9628f56504d 100644 (file)
@@ -258,7 +258,7 @@ class ThreadingExceptionTests(unittest.TestCase):
 
     def test_semaphore_with_negative_value(self):
         self.assertRaises(ValueError, threading.Semaphore, value = -1)
-        self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint)
+        self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxsize)
 
     def test_joining_current_thread(self):
         currentThread = threading.currentThread()
index 70c281f18bfe7bf469fc21f3e08e33d616f3f2ce..00143230ec2dd0f82a4cb781fb034d25278b5b61 100644 (file)
@@ -105,7 +105,7 @@ class TypesTests(unittest.TestCase):
         if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912):
             self.fail('int mul commutativity')
         # And another.
-        m = -sys.maxint - 1
+        m = -sys.maxsize - 1
         for divisor in 1, 2, 4, 8, 16, 32:
             j = m // divisor
             prod = divisor * j
@@ -122,7 +122,7 @@ class TypesTests(unittest.TestCase):
                 self.fail("expected type(%r) to be long, not %r" %
                                    (prod, type(prod)))
         # Check for expected * overflow to long.
-        m = sys.maxint
+        m = sys.maxsize
         for divisor in 1, 2, 4, 8, 16, 32:
             j = m // divisor + 1
             prod = divisor * j
@@ -137,7 +137,7 @@ class TypesTests(unittest.TestCase):
         if (-12) + (-24) != -36: self.fail('long op')
         if not 12 < 24: self.fail('long op')
         if not -24 < -12: self.fail('long op')
-        x = sys.maxint
+        x = sys.maxsize
         if int(int(x)) != x: self.fail('long op')
         try: y = int(int(x)+1)
         except OverflowError: self.fail('long op')
index fe4eb8581194bff8ae5949408f5fe7c336b3dced..eed84929cfdeabd27dca13e248a0194ca4a6f618 100644 (file)
@@ -1055,9 +1055,9 @@ class UnicodeTest(
         # This test only affects 32-bit platforms because expandtabs can only take
         # an int as the max value, not a 64-bit C long.  If expandtabs is changed
         # to take a 64-bit long, this test should apply to all platforms.
-        if sys.maxint > (1 << 32) or struct.calcsize('P') != 4:
+        if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4:
             return
-        self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint)
+        self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize)
 
 
 def test_main():
index e54ca19f93db88ff39d6ed7a473f9cea295acf99..26747168e6ae50f9b3ec18ea0a643197baee158d 100644 (file)
@@ -117,7 +117,7 @@ class XMLRPCTestCase(unittest.TestCase):
         self.assertRaises(TypeError, xmlrpclib.dumps, (d,))
 
     def test_dump_big_int(self):
-        if sys.maxint > 2**31-1:
+        if sys.maxsize > 2**31-1:
             self.assertRaises(OverflowError, xmlrpclib.dumps,
                               (int(2**34),))
 
index 97f639d57c06c10d23e008287bf031f2d2c5ac4e..b274682e7042d2b32ada927aba83ba207de6ca77 100644 (file)
@@ -428,7 +428,7 @@ class ZipExtFile:
            read a whole line.
         """
         if size < 0:
-            size = sys.maxint
+            size = sys.maxsize
         elif size == 0:
             return b''
 
index 465026a470bab3d0d211911e95934c72a66050f5..c041d106b21748d465f0fbb604a10c625372bba8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,8 @@ Core and Builtins
   to longobject.h. It still exists to define several aliases from PyInt_
   to PyLong_ functions.
 
+- Removed sys.maxint, use sys.maxsize instead.
+
 
 Extension Modules
 -----------------
index cf7cb4713b18ac4d1e3786e8f9ad6c1b5514ecf1..1df7c5ddfc725e9282dd126101bfe30674750f6c 100644 (file)
@@ -9,12 +9,6 @@
 
 #include <ctype.h>
 
-long
-PyInt_GetMax(void)
-{
-       return LONG_MAX;        /* To initialize sys.maxint */
-}
-
 #ifndef NSMALLPOSINTS
 #define NSMALLPOSINTS          257
 #endif
index e77b1f68050c7ea41c430a3d79f0ccac40812cec..69732cc04e0752ea2b475d99db1226f0159768e9 100644 (file)
@@ -1078,8 +1078,6 @@ _PySys_Init(void)
                            PyUnicode_DecodeFSDefault(Py_GetPrefix()));
        SET_SYS_FROM_STRING("exec_prefix",
                            PyUnicode_DecodeFSDefault(Py_GetExecPrefix()));
-       SET_SYS_FROM_STRING("maxint",
-                           PyLong_FromLong(PyInt_GetMax()));
        SET_SYS_FROM_STRING("maxsize",
                            PyLong_FromSsize_t(PY_SSIZE_T_MAX));
        SET_SYS_FROM_STRING("float_info",
index 510714dd5fed5929c286eaccbc80cee41b578a85..58acb828955fcc6898cc7fb03178761c30b5fbcf 100755 (executable)
@@ -96,13 +96,13 @@ def pytify(body):
     body = p_char.sub('ord(\\0)', body)
     # Compute negative hexadecimal constants
     start = 0
-    UMAX = 2*(sys.maxint+1)
+    UMAX = 2*(sys.maxsize+1)
     while 1:
         m = p_hex.search(body, start)
         if not m: break
         s,e = m.span()
         val = long(body[slice(*m.span(1))], 16)
-        if val > sys.maxint:
+        if val > sys.maxsize:
             val -= UMAX
             body = body[:s] + "(" + str(val) + ")" + body[e:]
         start = s + 1
index 3778efa6de564700fe07545ff24d5aea4c9b5f4c..5b5b5dc7c1ed753c250078378255b355e9dbae08 100644 (file)
@@ -948,7 +948,7 @@ def splitbins(t, trace=0):
             n >>= 1
             maxshift += 1
     del n
-    bytes = sys.maxint  # smallest total size so far
+    bytes = sys.maxsize  # smallest total size so far
     t = tuple(t)    # so slices can be dict keys
     for shift in range(maxshift + 1):
         t1 = []
index ff2e31be2fb545551aed1d21b9265f8904e3cb62..450bf5d17cdf4deb268a54bb15d9100b873798ec 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1074,7 +1074,7 @@ class PyBuildExt(build_ext):
                                   ['cjkcodecs/_codecs_%s.c' % loc]))
 
         # Dynamic loading module
-        if sys.maxint == 0x7fffffff:
+        if sys.maxsize == 0x7fffffff:
             # This requires sizeof(int) == sizeof(long) == sizeof(char*)
             dl_inc = find_file('dlfcn.h', [], inc_dirs)
             if (dl_inc is not None) and (platform not in ['atheos']):