Commits

Philip Jenvey  committed 6ea19b5 Merge

merge default

  • Participants
  • Parent commits 92b54ee, a401eb4
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/__pypy__/test/test_intop.py

 
     def w_intmask(self, n):
         import sys
-        n &= (sys.maxint*2+1)
-        if n > sys.maxint:
-            n -= 2*(sys.maxint+1)
+        n &= (sys.maxsize*2+1)
+        if n > sys.maxsize:
+            n -= 2*(sys.maxsize+1)
         return int(n)
 
     def test_intmask(self):
         import sys
-        assert self.intmask(sys.maxint) == sys.maxint
-        assert self.intmask(sys.maxint+1) == -sys.maxint-1
-        assert self.intmask(-sys.maxint-2) == sys.maxint
+        assert self.intmask(sys.maxsize) == sys.maxsize
+        assert self.intmask(sys.maxsize+1) == -sys.maxsize-1
+        assert self.intmask(-sys.maxsize-2) == sys.maxsize
         N = 2 ** 128
-        assert self.intmask(N+sys.maxint) == sys.maxint
-        assert self.intmask(N+sys.maxint+1) == -sys.maxint-1
-        assert self.intmask(N-sys.maxint-2) == sys.maxint
+        assert self.intmask(N+sys.maxsize) == sys.maxsize
+        assert self.intmask(N+sys.maxsize+1) == -sys.maxsize-1
+        assert self.intmask(N-sys.maxsize-2) == sys.maxsize
 
     def test_int_add(self):
         import sys
         from __pypy__ import intop
         assert intop.int_add(40, 2) == 42
-        assert intop.int_add(sys.maxint, 1) == -sys.maxint-1
-        assert intop.int_add(-2, -sys.maxint) == sys.maxint
+        assert intop.int_add(sys.maxsize, 1) == -sys.maxsize-1
+        assert intop.int_add(-2, -sys.maxsize) == sys.maxsize
 
     def test_int_sub(self):
         import sys
         from __pypy__ import intop
         assert intop.int_sub(40, -2) == 42
-        assert intop.int_sub(sys.maxint, -1) == -sys.maxint-1
-        assert intop.int_sub(-2, sys.maxint) == sys.maxint
+        assert intop.int_sub(sys.maxsize, -1) == -sys.maxsize-1
+        assert intop.int_sub(-2, sys.maxsize) == sys.maxsize
 
     def test_int_mul(self):
         import sys
         from __pypy__ import intop
         assert intop.int_mul(40, -2) == -80
-        assert intop.int_mul(-sys.maxint, -sys.maxint) == (
-            self.intmask(sys.maxint ** 2))
+        assert intop.int_mul(-sys.maxsize, -sys.maxsize) == (
+            self.intmask(sys.maxsize ** 2))
 
     def test_int_floordiv(self):
         import sys
         assert intop.int_floordiv(41, -3) == -13
         assert intop.int_floordiv(-41, 3) == -13
         assert intop.int_floordiv(-41, -3) == 13
-        assert intop.int_floordiv(-sys.maxint, -1) == sys.maxint
-        assert intop.int_floordiv(sys.maxint, -1) == -sys.maxint
+        assert intop.int_floordiv(-sys.maxsize, -1) == sys.maxsize
+        assert intop.int_floordiv(sys.maxsize, -1) == -sys.maxsize
 
     def test_int_mod(self):
         import sys
         assert intop.int_mod(41, -3) == 2
         assert intop.int_mod(-41, 3) == -2
         assert intop.int_mod(-41, -3) == -2
-        assert intop.int_mod(-sys.maxint, -1) == 0
-        assert intop.int_mod(sys.maxint, -1) == 0
+        assert intop.int_mod(-sys.maxsize, -1) == 0
+        assert intop.int_mod(sys.maxsize, -1) == 0
 
     def test_int_lshift(self):
         import sys
         from __pypy__ import intop
-        if sys.maxint == 2**31-1:
+        if sys.maxsize == 2**31-1:
             bits = 32
         else:
             bits = 64
         assert intop.int_lshift(42, 3) == 42 << 3
         assert intop.int_lshift(0, 3333) == 0
         assert intop.int_lshift(1, bits-2) == 1 << (bits-2)
-        assert intop.int_lshift(1, bits-1) == -sys.maxint-1 == (-1) << (bits-1)
+        assert intop.int_lshift(1, bits-1) == -sys.maxsize-1 == (-1) << (bits-1)
         assert intop.int_lshift(-1, bits-2) == (-1) << (bits-2)
-        assert intop.int_lshift(-1, bits-1) == -sys.maxint-1
-        assert intop.int_lshift(sys.maxint // 3, 2) == (
-            self.intmask((sys.maxint // 3) << 2))
-        assert intop.int_lshift(-sys.maxint // 3, 2) == (
-            self.intmask((-sys.maxint // 3) << 2))
+        assert intop.int_lshift(-1, bits-1) == -sys.maxsize-1
+        assert intop.int_lshift(sys.maxsize // 3, 2) == (
+            self.intmask((sys.maxsize // 3) << 2))
+        assert intop.int_lshift(-sys.maxsize // 3, 2) == (
+            self.intmask((-sys.maxsize // 3) << 2))
 
     def test_int_rshift(self):
         from __pypy__ import intop
     def test_uint_rshift(self):
         import sys
         from __pypy__ import intop
-        if sys.maxint == 2**31-1:
+        if sys.maxsize == 2**31-1:
             bits = 32
         else:
             bits = 64
         assert intop.uint_rshift(-42, 3) == (N-42) >> 3
         assert intop.uint_rshift(0, 3333) == 0
         assert intop.uint_rshift(-1, 0) == -1
-        assert intop.uint_rshift(-1, 1) == sys.maxint
+        assert intop.uint_rshift(-1, 1) == sys.maxsize
         assert intop.uint_rshift(-1, bits-2) == 3
         assert intop.uint_rshift(-1, bits-1) == 1

File pypy/module/test_lib_pypy/support.py

         return getattr(mod, name)
 
     try:
-        # Assume app-level import finds it from the right place (we
-        # assert so afterwards). It should as long as a builtin module
-        # overshadows it
-        w_mod = space.appexec([], "(): import %s; return %s" % (name, name))
+        # app-level import should find it from the right place (we
+        # assert so afterwards) as long as a builtin module doesn't
+        # overshadow it
+        failed = ("%s didn't import from lib_pypy. Is a usemodules directive "
+                  "overshadowing it?" % name)
+        importline = ("(): import %s; assert 'lib_pypy' in %s.__file__, %r; "
+                      "return %s" % (name, name, failed, name))
+        return space.appexec([], importline)
     except OperationError as e:
         if skipmsg is None or not e.match(space, space.w_ImportError):
             raise
         py.test.skip('%s (%s))' % (skipmsg, str(e)))
-    w_file = space.getattr(w_mod, space.wrap('__file__'))
-    assert space.is_true(space.contains(w_file, space.wrap('lib_pypy'))), \
-        ("%s didn't import from lib_pypy. Is a usemodules directive "
-         "overshadowing it?" % name)
-    return w_mod