Author: Philip Jenvey <pjen...@underboss.org>
Branch: py3k
Changeset: r65493:bce5675fd138
Date: 2013-07-19 17:19 -0700
http://bitbucket.org/pypy/pypy/changeset/bce5675fd138/

Log:    adapt to py3

diff --git a/pypy/module/test_lib_pypy/test_resource.py 
b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -37,5 +37,5 @@
             if i < 2:
                 expected_type = float
             else:
-                expected_type = (int, long)
+                expected_type = int
             assert isinstance(x[i], expected_type)
diff --git a/pypy/module/test_lib_pypy/test_structseq.py 
b/pypy/module/test_lib_pypy/test_structseq.py
--- a/pypy/module/test_lib_pypy/test_structseq.py
+++ b/pypy/module/test_lib_pypy/test_structseq.py
@@ -10,30 +10,32 @@
 
     def w_get_mydata(self):
         _structseq = self._structseq
-        ssfield = _structseq.structseqfield
-        class mydata:
-            __metaclass__ = _structseq.structseqtype
-
-            st_mode  = ssfield(0, "protection bits")
-            st_ino   = ssfield(1)
-            st_dev   = ssfield(2)
-            st_nlink = ssfield(3)
-            st_uid   = ssfield(4)
-            st_gid   = ssfield(5)
-            st_size  = ssfield(6)
-            _st_atime_as_int = ssfield(7)
-            _st_mtime_as_int = ssfield(8)
-            _st_ctime_as_int = ssfield(9)
-            # skip to higher numbers for fields not part of the sequence.
-            # the numbers are only used to ordering
-            st_rdev  = ssfield(50, "device type (if inode device)")
-            st_atime = ssfield(57,
-                               default=lambda self: self._st_atime_as_int)
-            st_mtime = ssfield(58,
-                               default=lambda self: self._st_mtime_as_int)
-            st_ctime = ssfield(59,
-                               default=lambda self: self._st_ctime_as_int)
-        return mydata
+        ns = dict(_structseq=_structseq,
+                  ssfield=_structseq.structseqfield)
+        # need to exec since it uses the py3k-only metaclass syntax
+        exec("""\
+class mydata(metaclass=_structseq.structseqtype):
+    st_mode  = ssfield(0, "protection bits")
+    st_ino   = ssfield(1)
+    st_dev   = ssfield(2)
+    st_nlink = ssfield(3)
+    st_uid   = ssfield(4)
+    st_gid   = ssfield(5)
+    st_size  = ssfield(6)
+    _st_atime_as_int = ssfield(7)
+    _st_mtime_as_int = ssfield(8)
+    _st_ctime_as_int = ssfield(9)
+    # skip to higher numbers for fields not part of the sequence.
+    # the numbers are only used to ordering
+    st_rdev  = ssfield(50, "device type (if inode device)")
+    st_atime = ssfield(57,
+                       default=lambda self: self._st_atime_as_int)
+    st_mtime = ssfield(58,
+                       default=lambda self: self._st_mtime_as_int)
+    st_ctime = ssfield(59,
+                       default=lambda self: self._st_ctime_as_int)
+""", ns)
+        return ns['mydata']
 
     def test_class(self):
         mydata = self.get_mydata()
@@ -52,7 +54,7 @@
         assert x.st_ctime == 109    # copied by the default=lambda...
         assert x.st_rdev  == 110
         assert len(x)     == 10
-        assert list(x)    == range(100, 110)
+        assert list(x)    == list(range(100, 110))
         assert x + (5,)   == tuple(range(100, 110)) + (5,)
         assert x[4:12:2]  == (104, 106, 108)
         assert 104 in x
@@ -72,7 +74,7 @@
     def test_compare_like_tuple(self):
         mydata = self.get_mydata()
         x = mydata(range(100, 111))
-        y = mydata(range(100, 110) + [555])
+        y = mydata(list(range(100, 110)) + [555])
         assert x == tuple(range(100, 110))
         assert x == y    # blame CPython
         assert hash(x) == hash(y) == hash(tuple(range(100, 110)))
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to