Author: Alex Gaynor <[email protected]>
Branch: 
Changeset: r65309:9c5869afb49c
Date: 2013-07-10 09:27 +1000
http://bitbucket.org/pypy/pypy/changeset/9c5869afb49c/

Log:    More 4-space indentation fixes.

diff --git a/pypy/interpreter/test/test_nestedscope.py 
b/pypy/interpreter/test/test_nestedscope.py
--- a/pypy/interpreter/test/test_nestedscope.py
+++ b/pypy/interpreter/test/test_nestedscope.py
@@ -73,7 +73,7 @@
 
         def f():
             def f(y):
-                  return x + y
+                return x + y
             return f
             x = 1
 
@@ -85,7 +85,7 @@
             if n:
                 x = 42
             def f(y):
-                  return x + y
+                return x + y
             return f
 
         g0 = f(0).func_closure[0]
diff --git a/pypy/module/cppyy/test/test_advancedcpp.py 
b/pypy/module/cppyy/test/test_advancedcpp.py
--- a/pypy/module/cppyy/test/test_advancedcpp.py
+++ b/pypy/module/cppyy/test/test_advancedcpp.py
@@ -542,7 +542,7 @@
 
         # TODO: get the capi-identify test selection right ...
         if self.capi_identity != 'CINT':     # don't test anything for Reflex
-             return
+            return
 
         import cppyy
 
diff --git a/pypy/module/cppyy/test/test_cint.py 
b/pypy/module/cppyy/test/test_cint.py
--- a/pypy/module/cppyy/test/test_cint.py
+++ b/pypy/module/cppyy/test/test_cint.py
@@ -131,11 +131,11 @@
         # TVectorF is a typedef of floats
         v = cppyy.gbl.TVectorF(N)
         for i in range(N):
-             v[i] = i*i
+            v[i] = i*i
 
         assert len(v) == N
         for j in v:
-             assert round(v[int(math.sqrt(j)+0.5)]-j, 5) == 0.
+            assert round(v[int(math.sqrt(j)+0.5)]-j, 5) == 0.
 
 
 class AppTestCINTTTREE:
diff --git a/pypy/module/cppyy/test/test_stltypes.py 
b/pypy/module/cppyy/test/test_stltypes.py
--- a/pypy/module/cppyy/test/test_stltypes.py
+++ b/pypy/module/cppyy/test/test_stltypes.py
@@ -97,9 +97,9 @@
         assert hasattr(v, 'end' )
 
         for i in range(self.N):
-             v.push_back(cppyy.gbl.just_a_class())
-             v[i].m_i = i
-             assert v[i].m_i == i
+            v.push_back(cppyy.gbl.just_a_class())
+            v[i].m_i = i
+            assert v[i].m_i == i
 
         assert len(v) == self.N
         v.destruct()
@@ -332,7 +332,7 @@
 
         a = std.list(int)()
         for arg in a:
-           pass
+            pass
 
 
 class AppTestSTLMAP:
@@ -395,7 +395,7 @@
 
         m = std.map(int, int)()
         for key, value in m:
-           pass
+            pass
 
     def test04_unsignedvalue_typemap_types(self):
         """Test assignability of maps with unsigned value types"""
diff --git a/pypy/module/oracle/interp_pool.py 
b/pypy/module/oracle/interp_pool.py
--- a/pypy/module/oracle/interp_pool.py
+++ b/pypy/module/oracle/interp_pool.py
@@ -130,14 +130,14 @@
         self.checkConnected(space)
 
         if __args__.keywords:
-             keywords = __args__.keywords + ["pool"]
+            keywords = __args__.keywords + ["pool"]
         else:
-             keywords = ["pool"]
+            keywords = ["pool"]
         if __args__.keywords_w:
-             keywords_w = __args__.keywords_w + [space.wrap(self)]
+            keywords_w = __args__.keywords_w + [space.wrap(self)]
         else:
-             keywords_w = [space.wrap(self)]
-             
+            keywords_w = [space.wrap(self)]
+
         newargs = Arguments(space,
                             __args__.arguments_w,
                             keywords,
diff --git a/pypy/module/parser/pyparser.py b/pypy/module/parser/pyparser.py
--- a/pypy/module/parser/pyparser.py
+++ b/pypy/module/parser/pyparser.py
@@ -75,7 +75,7 @@
     info = pyparse.CompileInfo("<string>", mode)
     parser = pyparse.PythonParser(space)
     try:
-       tree = parser.parse_source(source, info)
+        tree = parser.parse_source(source, info)
     except error.IndentationError, e:
         raise OperationError(space.w_IndentationError,
                              e.wrap_info(space))
diff --git a/pypy/module/pyexpat/test/test_build.py 
b/pypy/module/pyexpat/test/test_build.py
--- a/pypy/module/pyexpat/test/test_build.py
+++ b/pypy/module/pyexpat/test/test_build.py
@@ -12,7 +12,7 @@
     py.test.skip("No module expat")
 
 try:
-   from pypy.module.pyexpat import interp_pyexpat
+    from pypy.module.pyexpat import interp_pyexpat
 except (ImportError, CompilationError):
     py.test.skip("Expat not installed")
 
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py 
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -63,7 +63,7 @@
         offset = {}
         for i, op in enumerate(oplist):
             if i != 1:
-               offset[op] = i
+                offset[op] = i
 
         token = JitCellToken()
         token.number = 0
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py 
b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -91,13 +91,13 @@
         next(cur)
 
 def test_cursor_after_close(con):
-     cur = con.execute('select 1')
-     cur.close()
-     con.close()
-     pytest.raises(_sqlite3.ProgrammingError, "cur.close()")
-     # raises ProgrammingError because should check closed before check args
-     pytest.raises(_sqlite3.ProgrammingError, "cur.execute(1,2,3,4,5)")
-     pytest.raises(_sqlite3.ProgrammingError, "cur.executemany(1,2,3,4,5)")
+    cur = con.execute('select 1')
+    cur.close()
+    con.close()
+    pytest.raises(_sqlite3.ProgrammingError, "cur.close()")
+    # raises ProgrammingError because should check closed before check args
+    pytest.raises(_sqlite3.ProgrammingError, "cur.execute(1,2,3,4,5)")
+    pytest.raises(_sqlite3.ProgrammingError, "cur.executemany(1,2,3,4,5)")
 
 @pytest.mark.skipif("not hasattr(sys, 'pypy_translation_info')")
 def test_connection_del(tmpdir):
diff --git a/pypy/objspace/std/test/test_methodcache.py 
b/pypy/objspace/std/test/test_methodcache.py
--- a/pypy/objspace/std/test/test_methodcache.py
+++ b/pypy/objspace/std/test/test_methodcache.py
@@ -24,150 +24,150 @@
         """)
 
     def test_mix_classes(self):
-      @self.retry
-      def run():
-        import __pypy__
-        class A(object):
-            def f(self):
-                return 42
-        class B(object):
-            def f(self):
-                return 43
-        class C(object):
-            def f(self):
-                return 44
-        l = [A(), B(), C()] * 10
-        __pypy__.reset_method_cache_counter()
-        for i, a in enumerate(l):
-            assert a.f() == 42 + i % 3
-        cache_counter = __pypy__.method_cache_counter("f")
-        assert cache_counter[0] >= 15
-        assert cache_counter[1] >= 3 # should be (27, 3)
-        assert sum(cache_counter) == 30
+        @self.retry
+        def run():
+            import __pypy__
+            class A(object):
+                def f(self):
+                    return 42
+            class B(object):
+                def f(self):
+                    return 43
+            class C(object):
+                def f(self):
+                    return 44
+            l = [A(), B(), C()] * 10
+            __pypy__.reset_method_cache_counter()
+            for i, a in enumerate(l):
+                assert a.f() == 42 + i % 3
+            cache_counter = __pypy__.method_cache_counter("f")
+            assert cache_counter[0] >= 15
+            assert cache_counter[1] >= 3 # should be (27, 3)
+            assert sum(cache_counter) == 30
 
     def test_class_that_cannot_be_cached(self):
-      @self.retry
-      def run():
-        import __pypy__
-        class X:
-            pass
-        class Y(object):
-            pass
-        class A(Y, X):
-            def f(self):
-                return 42
+        @self.retry
+        def run():
+            import __pypy__
+            class X:
+                pass
+            class Y(object):
+                pass
+            class A(Y, X):
+                def f(self):
+                    return 42
 
-        class B(object):
-            def f(self):
-                return 43
-        class C(object):
-            def f(self):
-                return 44
-        l = [A(), B(), C()] * 10
-        __pypy__.reset_method_cache_counter()
-        for i, a in enumerate(l):
-            assert a.f() == 42 + i % 3
-        cache_counter = __pypy__.method_cache_counter("f")
-        assert cache_counter[0] >= 9
-        assert cache_counter[1] >= 2 # should be (18, 2)
-        assert sum(cache_counter) == 20
- 
+            class B(object):
+                def f(self):
+                    return 43
+            class C(object):
+                def f(self):
+                    return 44
+            l = [A(), B(), C()] * 10
+            __pypy__.reset_method_cache_counter()
+            for i, a in enumerate(l):
+                assert a.f() == 42 + i % 3
+            cache_counter = __pypy__.method_cache_counter("f")
+            assert cache_counter[0] >= 9
+            assert cache_counter[1] >= 2 # should be (18, 2)
+            assert sum(cache_counter) == 20
+
     def test_change_methods(self):
-      @self.retry
-      def run():
-        import __pypy__
-        class A(object):
-            def f(self):
-                return 42
-        l = [A()] * 10
-        __pypy__.reset_method_cache_counter()
-        for i, a in enumerate(l):
-            assert a.f() == 42 + i
-            A.f = eval("lambda self: %s" % (42 + i + 1, ))
-        cache_counter = __pypy__.method_cache_counter("f")
-        #
-        # a bit of explanation about what's going on.  (1) is the line "a.f()"
-        # and (2) is "A.f = ...".
-        #
-        # at line (1) we do the lookup on type(a).f
-        #
-        # at line (2) we do a setattr on A. However, descr_setattr does also a
-        # lookup of type(A).f i.e. type.f, to check if by chance 'f' is a data
-        # descriptor.
-        #
-        # At the first iteration:
-        # (1) is a miss because it's the first lookup of A.f. The result is 
cached
-        #
-        # (2) is a miss because it is the first lookup of type.f. The
-        # (non-existant) result is cached. The version of A changes, and 'f'
-        # is changed to be a cell object, so that subsequest assignments won't
-        # change the version of A
-        #
-        # At the second iteration:
-        # (1) is a miss because the version of A changed just before
-        # (2) is a hit, because type.f is cached. The version of A no longer 
changes
-        #
-        # At the third and subsequent iterations:
-        # (1) is a hit, because the version of A did not change
-        # (2) is a hit, see above
-        assert cache_counter == (17, 3)
+        @self.retry
+        def run():
+            import __pypy__
+            class A(object):
+                def f(self):
+                    return 42
+            l = [A()] * 10
+            __pypy__.reset_method_cache_counter()
+            for i, a in enumerate(l):
+                assert a.f() == 42 + i
+                A.f = eval("lambda self: %s" % (42 + i + 1, ))
+            cache_counter = __pypy__.method_cache_counter("f")
+            #
+            # a bit of explanation about what's going on.  (1) is the line 
"a.f()"
+            # and (2) is "A.f = ...".
+            #
+            # at line (1) we do the lookup on type(a).f
+            #
+            # at line (2) we do a setattr on A. However, descr_setattr does 
also a
+            # lookup of type(A).f i.e. type.f, to check if by chance 'f' is a 
data
+            # descriptor.
+            #
+            # At the first iteration:
+            # (1) is a miss because it's the first lookup of A.f. The result 
is cached
+            #
+            # (2) is a miss because it is the first lookup of type.f. The
+            # (non-existant) result is cached. The version of A changes, and 
'f'
+            # is changed to be a cell object, so that subsequest assignments 
won't
+            # change the version of A
+            #
+            # At the second iteration:
+            # (1) is a miss because the version of A changed just before
+            # (2) is a hit, because type.f is cached. The version of A no 
longer changes
+            #
+            # At the third and subsequent iterations:
+            # (1) is a hit, because the version of A did not change
+            # (2) is a hit, see above
+            assert cache_counter == (17, 3)
 
     def test_subclasses(self):
-      @self.retry
-      def run():
-        import __pypy__
-        class A(object):
-            def f(self):
-                return 42
-        class B(object):
-            def f(self):
-                return 43
-        class C(A):
-            pass
-        l = [A(), B(), C()] * 10
-        __pypy__.reset_method_cache_counter()
-        for i, a in enumerate(l):
-            assert a.f() == 42 + (i % 3 == 1)
-        cache_counter = __pypy__.method_cache_counter("f")
-        assert cache_counter[0] >= 15
-        assert cache_counter[1] >= 3 # should be (27, 3)
-        assert sum(cache_counter) == 30
-  
+        @self.retry
+        def run():
+            import __pypy__
+            class A(object):
+                def f(self):
+                    return 42
+            class B(object):
+                def f(self):
+                    return 43
+            class C(A):
+                pass
+            l = [A(), B(), C()] * 10
+            __pypy__.reset_method_cache_counter()
+            for i, a in enumerate(l):
+                assert a.f() == 42 + (i % 3 == 1)
+            cache_counter = __pypy__.method_cache_counter("f")
+            assert cache_counter[0] >= 15
+            assert cache_counter[1] >= 3 # should be (27, 3)
+            assert sum(cache_counter) == 30
+
     def test_many_names(self):
-      @self.retry
-      def run():
-        import __pypy__
-        for j in range(20):
-            class A(object):
-                foo = 5
-                bar = 6
-                baz = 7
-                xyz = 8
-                stuff = 9
-                a = 10
-                foobar = 11
+        @self.retry
+        def run():
+            import __pypy__
+            for j in range(20):
+                class A(object):
+                    foo = 5
+                    bar = 6
+                    baz = 7
+                    xyz = 8
+                    stuff = 9
+                    a = 10
+                    foobar = 11
 
-            a = A()
-            names = [name for name in A.__dict__.keys()
-                          if not name.startswith('_')]
-            names.sort()
-            names_repeated = names * 10
-            result = []
-            __pypy__.reset_method_cache_counter()
-            for name in names_repeated:
-                result.append(getattr(a, name))
-            append_counter = __pypy__.method_cache_counter("append")
-            names_counters = [__pypy__.method_cache_counter(name)
-                              for name in names]
-            try:
-                assert append_counter[0] >= 10 * len(names) - 1
-                for name, count in zip(names, names_counters):
-                    assert count == (9, 1), str((name, count))
-                break
-            except AssertionError:
-                pass
-        else:
-            raise
+                a = A()
+                names = [name for name in A.__dict__.keys()
+                              if not name.startswith('_')]
+                names.sort()
+                names_repeated = names * 10
+                result = []
+                __pypy__.reset_method_cache_counter()
+                for name in names_repeated:
+                    result.append(getattr(a, name))
+                append_counter = __pypy__.method_cache_counter("append")
+                names_counters = [__pypy__.method_cache_counter(name)
+                                  for name in names]
+                try:
+                    assert append_counter[0] >= 10 * len(names) - 1
+                    for name, count in zip(names, names_counters):
+                        assert count == (9, 1), str((name, count))
+                    break
+                except AssertionError:
+                    pass
+            else:
+                raise
 
     def test_mutating_bases(self):
         class C(object):
@@ -189,50 +189,50 @@
         assert e.foo == 3
 
     def test_custom_metaclass(self):
-      @self.retry
-      def run():
-        import __pypy__
-        for j in range(20):
-            class MetaA(type):
-                def __getattribute__(self, x):
-                    return 1
-            def f(self):
-                return 42
-            A = type.__new__(MetaA, "A", (), {"f": f})
-            l = [type.__getattribute__(A, "__new__")(A)] * 10
-            __pypy__.reset_method_cache_counter()
-            for i, a in enumerate(l):
-                assert a.f() == 42
-            cache_counter = __pypy__.method_cache_counter("f")
-            assert sum(cache_counter) == 10
-            if cache_counter == (9, 1):
-                break
-            #else the moon is misaligned, try again
-        else:
-            raise AssertionError("cache_counter = %r" % (cache_counter,))
+        @self.retry
+        def run():
+            import __pypy__
+            for j in range(20):
+                class MetaA(type):
+                    def __getattribute__(self, x):
+                        return 1
+                def f(self):
+                    return 42
+                A = type.__new__(MetaA, "A", (), {"f": f})
+                l = [type.__getattribute__(A, "__new__")(A)] * 10
+                __pypy__.reset_method_cache_counter()
+                for i, a in enumerate(l):
+                    assert a.f() == 42
+                cache_counter = __pypy__.method_cache_counter("f")
+                assert sum(cache_counter) == 10
+                if cache_counter == (9, 1):
+                    break
+                #else the moon is misaligned, try again
+            else:
+                raise AssertionError("cache_counter = %r" % (cache_counter,))
 
     def test_mutate_class(self):
-      @self.retry
-      def run():
-        import __pypy__
-        class A(object):
-            x = 1
-            y = 2
-        __pypy__.reset_method_cache_counter()
-        a = A()
-        for i in range(100):
-            assert a.y == 2
-            assert a.x == i + 1
-            A.x += 1
-        cache_counter = __pypy__.method_cache_counter("x")
-        assert cache_counter[0] >= 350
-        assert cache_counter[1] >= 1
-        assert sum(cache_counter) == 400
+        @self.retry
+        def run():
+            import __pypy__
+            class A(object):
+                x = 1
+                y = 2
+            __pypy__.reset_method_cache_counter()
+            a = A()
+            for i in range(100):
+                assert a.y == 2
+                assert a.x == i + 1
+                A.x += 1
+            cache_counter = __pypy__.method_cache_counter("x")
+            assert cache_counter[0] >= 350
+            assert cache_counter[1] >= 1
+            assert sum(cache_counter) == 400
 
-        __pypy__.reset_method_cache_counter()
-        a = A()
-        for i in range(100):
-            assert a.y == 2
-            setattr(a, "a%s" % i, i)
-        cache_counter = __pypy__.method_cache_counter("x")
-        assert cache_counter[0] == 0 # 0 hits, because all the attributes are 
new
+            __pypy__.reset_method_cache_counter()
+            a = A()
+            for i in range(100):
+                assert a.y == 2
+                setattr(a, "a%s" % i, i)
+            cache_counter = __pypy__.method_cache_counter("x")
+            assert cache_counter[0] == 0 # 0 hits, because all the attributes 
are new
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -378,11 +378,11 @@
 
     if left:
         while lpos < rpos and _isspace(u_self[lpos]):
-           lpos += 1
+            lpos += 1
 
     if right:
         while rpos > lpos and _isspace(u_self[rpos - 1]):
-           rpos -= 1
+            rpos -= 1
 
     assert rpos >= 0
     result = u_self[lpos: rpos]
diff --git a/pypy/objspace/test/test_descroperation.py 
b/pypy/objspace/test/test_descroperation.py
--- a/pypy/objspace/test/test_descroperation.py
+++ b/pypy/objspace/test/test_descroperation.py
@@ -318,12 +318,13 @@
             raises(TypeError, operate, A())
 
     def test_missing_getattribute(self):
-        class X(object): pass
+        class X(object):
+            pass
 
         class Y(X):
-          class __metaclass__(type):
-            def mro(cls):
-              return [cls, X]
+            class __metaclass__(type):
+                def mro(cls):
+                    return [cls, X]
 
         x = X()
         x.__class__ = Y
@@ -331,8 +332,10 @@
 
     def test_silly_but_consistent_order(self):
         # incomparable objects sort by type name :-/
-        class A(object): pass
-        class zz(object): pass
+        class A(object):
+            pass
+        class zz(object):
+            pass
         assert A() < zz()
         assert zz() > A()
         # if in doubt, CPython sorts numbers before non-numbers
diff --git a/pypy/tool/pytest/result.py b/pypy/tool/pytest/result.py
--- a/pypy/tool/pytest/result.py
+++ b/pypy/tool/pytest/result.py
@@ -1,53 +1,53 @@
-import sys 
+import sys
 import py
 import re
 
-class Result(object): 
-    def __init__(self, init=True): 
+class Result(object):
+    def __init__(self, init=True):
         self._headers = {}
         self._blocks = {}
         self._blocknames = []
-        if init: 
-            stdinit(self) 
+        if init:
+            stdinit(self)
 
-    def __setitem__(self, name, value): 
-        self._headers[name.lower()] = value 
+    def __setitem__(self, name, value):
+        self._headers[name.lower()] = value
 
-    def __getitem__(self, name): 
+    def __getitem__(self, name):
         return self._headers[name.lower()]
 
-    def get(self, name, default): 
-        return self._headers.get(name, default) 
-    
-    def __delitem__(self, name): 
+    def get(self, name, default):
+        return self._headers.get(name, default)
+
+    def __delitem__(self, name):
         del self._headers[name.lower()]
 
-    def items(self): 
+    def items(self):
         return self._headers.items()
 
-    def addnamedtext(self, name, text): 
+    def addnamedtext(self, name, text):
         assert isinstance(text, basestring)
         assert isinstance(name, str)
-        self._blocknames.append(name) 
-        self._blocks[name] = text 
+        self._blocknames.append(name)
+        self._blocks[name] = text
 
-    def getnamedtext(self, name): 
+    def getnamedtext(self, name):
         return self._blocks[name]
 
-    def repr_short_error(self): 
-        if not self.isok(): 
-            if 'reportdiff' in self._blocks: 
+    def repr_short_error(self):
+        if not self.isok():
+            if 'reportdiff' in self._blocks:
                 return "output comparison failed, see reportdiff"
-            else: 
-                text = self.getnamedtext('stderr') 
+            else:
+                text = self.getnamedtext('stderr')
                 lines = text.strip().split('\n')
-                if lines: 
+                if lines:
                     return lines[-1]
 
-    def repr_mimemessage(self): 
-        from email.MIMEMultipart  import MIMEMultipart 
+    def repr_mimemessage(self):
+        from email.MIMEMultipart  import MIMEMultipart
         from email.MIMEText  import MIMEText
-        
+
         outer = MIMEMultipart()
         items = self._headers.items()
         items.sort()
@@ -56,31 +56,31 @@
             assert ':' not in name
             chars = map(ord, name)
             assert min(chars) >= 33 and max(chars) <= 126
-            outer[name] = str(value) 
-            if not isinstance(value, str): 
-                typename = type(value).__name__ 
+            outer[name] = str(value)
+            if not isinstance(value, str):
+                typename = type(value).__name__
                 assert typename in vars(py.std.__builtin__)
-                reprs[name] = typename 
+                reprs[name] = typename
 
-        outer['_reprs'] = repr(reprs) 
-    
-        for name in self._blocknames: 
+        outer['_reprs'] = repr(reprs)
+
+        for name in self._blocknames:
             text = self._blocks[name]
             m = MIMEText(text)
             m.add_header('Content-Disposition', 'attachment', filename=name)
-            outer.attach(m) 
-        return outer 
+            outer.attach(m)
+        return outer
 
     def grep_nr(self,text,section='stdout'):
         stdout = self._blocks[section]
         find = re.search('%s(?P<nr>\d+)'%text,stdout)
-        if find: 
+        if find:
             return float(find.group('nr'))
-        return 0. 
+        return 0.
 
     def ratio_of_passed(self):
         if self.isok():
-            return 1.   
+            return 1.
         elif self.istimeout():
             return 0.
         else:
@@ -88,16 +88,16 @@
             if nr > 0:
                 return (nr - (self.grep_nr('errors=') + 
self.grep_nr('failures=')))/nr
             else:
-              passed = self.grep_nr('TestFailed: ',section='stderr')
-              run = self.grep_nr('TestFailed: \d+/',section='stderr')
-              if run > 0:
-                  return passed/run
-              else:
-                  run = self.grep_nr('TestFailed: \d+ of ',section='stderr')
-                  if run > 0 :
-                      return (run-passed)/run
-                  else:
-                      return 0.0
+                passed = self.grep_nr('TestFailed: ',section='stderr')
+                run = self.grep_nr('TestFailed: \d+/',section='stderr')
+                if run > 0:
+                    return passed/run
+                else:
+                    run = self.grep_nr('TestFailed: \d+ of ',section='stderr')
+                    if run > 0 :
+                        return (run-passed)/run
+                    else:
+                        return 0.0
 
     def isok(self):
         return self['outcome'].lower() == 'ok'
@@ -105,7 +105,7 @@
     def iserror(self):
         return self['outcome'].lower()[:3] == 'err' or self['outcome'].lower() 
== 'fail'
 
-    def istimeout(self): 
+    def istimeout(self):
         return self['outcome'].lower() == 't/o'
 
 # XXX backward compatibility
@@ -114,7 +114,7 @@
         return msg
     f = open(str(path), 'r')
     msg = f.read()
-    f.close()    
+    f.close()
     for broken in ('exit status', 'cpu model', 'cpu mhz'):
         valid = broken.replace(' ','-')
         invalid = msg.find(broken+':')
@@ -127,10 +127,10 @@
 def sanitize_reprs(reprs):
     if 'exit status' in reprs:
         reprs['exit-status'] = reprs.pop('exit status')
-            
-class ResultFromMime(Result): 
-    def __init__(self, path): 
-        super(ResultFromMime, self).__init__(init=False) 
+
+class ResultFromMime(Result):
+    def __init__(self, path):
+        super(ResultFromMime, self).__init__(init=False)
         f = open(str(path), 'r')
         from email import message_from_file
         msg = message_from_file(f)
@@ -142,48 +142,48 @@
         self._reprs = eval(msg['_reprs'])
         del msg['_reprs']
         sanitize_reprs(self._reprs)
-        for name, value in msg.items(): 
-            if name in self._reprs: 
+        for name, value in msg.items():
+            if name in self._reprs:
                 value = eval(value)  # XXX security
-            self._headers[name] = value 
+            self._headers[name] = value
         self.fspath = self['fspath']
-        if self['platform'] == 'win32' and '\\' in self.fspath: 
+        if self['platform'] == 'win32' and '\\' in self.fspath:
             self.testname = self.fspath.split('\\')[-1]
-        else: 
+        else:
             self.testname = self.fspath.split('/')[-1]
-        #if sys.platform != 'win32' and '\\' in self.fspath: 
+        #if sys.platform != 'win32' and '\\' in self.fspath:
         #    self.fspath = py.path.local(self['fspath'].replace('\\'
-        self.path = path 
-    
-        payload = msg.get_payload() 
-        if payload: 
-           for submsg in payload: 
+        self.path = path
+
+        payload = msg.get_payload()
+        if payload:
+            for submsg in payload:
                 assert submsg.get_content_type() == 'text/plain'
-                fn = submsg.get_filename() 
+                fn = submsg.get_filename()
                 assert fn
                 # XXX we need to deal better with encodings to
                 #     begin with
                 content = submsg.get_payload()
-                for candidate in 'utf8', 'latin1': 
+                for candidate in 'utf8', 'latin1':
                     try:
                         text = unicode(content, candidate)
-                    except UnicodeDecodeError: 
+                    except UnicodeDecodeError:
                         continue
                 else:
-                    unicode(content, candidate) 
-                self.addnamedtext(fn, text) 
+                    unicode(content, candidate)
+                self.addnamedtext(fn, text)
 
-    def ismodifiedtest(self): 
-        # XXX we need proper cross-platform paths! 
+    def ismodifiedtest(self):
+        # XXX we need proper cross-platform paths!
         return 'modified' in self.fspath
 
-    def __repr__(self): 
-        return '<%s (%s) %r rev=%s>' %(self.__class__.__name__, 
-                                  self['outcome'], 
-                                  self.fspath, 
+    def __repr__(self):
+        return '<%s (%s) %r rev=%s>' %(self.__class__.__name__,
+                                  self['outcome'],
+                                  self.fspath,
                                   self['pypy-revision'])
 
-def stdinit(result): 
+def stdinit(result):
     import getpass
     import socket
     try:
@@ -192,24 +192,24 @@
         username = 'unknown'
     userhost = '%s@%s' % (username, socket.gethostname())
     result['testreport-version'] = "1.1.1"
-    result['userhost'] = userhost 
-    result['platform'] = sys.platform 
-    result['python-version-info'] = sys.version_info 
-    info = try_getcpuinfo() 
+    result['userhost'] = userhost
+    result['platform'] = sys.platform
+    result['python-version-info'] = sys.version_info
+    info = try_getcpuinfo()
     if info is not None:
         result['cpu-model'] = info.get('model name', "unknown")
         result['cpu-mhz'] = info.get('cpu mhz', 'unknown')
 #
 #
 #
-def try_getcpuinfo(): 
-    if sys.platform.startswith('linux'): 
+def try_getcpuinfo():
+    if sys.platform.startswith('linux'):
         cpuinfopath = py.path.local('/proc/cpuinfo')
-        if cpuinfopath.check(file=1): 
+        if cpuinfopath.check(file=1):
             d = {}
-            for line in cpuinfopath.readlines(): 
-                if line.strip(): 
-                   name, value = line.split(':', 1)
-                   name = name.strip().lower()
-                   d[name] = value.strip()
-            return d 
+            for line in cpuinfopath.readlines():
+                if line.strip():
+                    name, value = line.split(':', 1)
+                    name = name.strip().lower()
+                    d[name] = value.strip()
+            return d
diff --git a/pypy/tool/slaveproc.py b/pypy/tool/slaveproc.py
--- a/pypy/tool/slaveproc.py
+++ b/pypy/tool/slaveproc.py
@@ -39,7 +39,7 @@
 
 class SlaveProcess(object):
     _broken = False
-    
+
     def __init__(self, slave_impl):
         if sys.platform == 'win32':
             unbuffered = ''
@@ -58,7 +58,7 @@
 
     def close(self):
         if not self._broken:
-             assert self.cmd(None) == 'done'
+            assert self.cmd(None) == 'done'
         self.exchg.forceclose()
 
 class Slave(object):
@@ -70,7 +70,7 @@
         exchg = Exchange(sys.stdin, sys.stdout)
         while True:
             try:
-               cmd = exchg.recv()
+                cmd = exchg.recv()
             except EOFError: # master died
                 break
             if cmd is None:
@@ -78,4 +78,3 @@
                 break
             result = self.do_cmd(cmd)
             exchg.send(result)
-        
diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py 
b/rpython/rtyper/lltypesystem/ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
@@ -900,123 +900,123 @@
         return llobj
 
 def ctypes2lltype(T, cobj):
-  """Convert the ctypes object 'cobj' to its lltype equivalent.
-  'T' is the expected lltype type.
-  """
-  with rlock:
-    if T is lltype.Void:
-        return None
-    if isinstance(T, lltype.Typedef):
-        T = T.OF
-    if isinstance(T, lltype.Ptr):
-        ptrval = ctypes.cast(cobj, ctypes.c_void_p).value
-        if not cobj or not ptrval:   # NULL pointer
-            # CFunctionType.__nonzero__ is broken before Python 2.6
-            return lltype.nullptr(T.TO)
-        if isinstance(T.TO, lltype.Struct):
-            if T.TO._gckind == 'gc' and ptrval & 1: # a tagged pointer
-                gcref = _opaque_objs[ptrval // 2].hide()
-                return lltype.cast_opaque_ptr(T, gcref)
-            REAL_TYPE = T.TO
-            if T.TO._arrayfld is not None:
-                carray = getattr(cobj.contents, T.TO._arrayfld)
-                container = lltype._struct(T.TO, carray.length)
+    """Convert the ctypes object 'cobj' to its lltype equivalent.
+    'T' is the expected lltype type.
+    """
+    with rlock:
+        if T is lltype.Void:
+            return None
+        if isinstance(T, lltype.Typedef):
+            T = T.OF
+        if isinstance(T, lltype.Ptr):
+            ptrval = ctypes.cast(cobj, ctypes.c_void_p).value
+            if not cobj or not ptrval:   # NULL pointer
+                # CFunctionType.__nonzero__ is broken before Python 2.6
+                return lltype.nullptr(T.TO)
+            if isinstance(T.TO, lltype.Struct):
+                if T.TO._gckind == 'gc' and ptrval & 1: # a tagged pointer
+                    gcref = _opaque_objs[ptrval // 2].hide()
+                    return lltype.cast_opaque_ptr(T, gcref)
+                REAL_TYPE = T.TO
+                if T.TO._arrayfld is not None:
+                    carray = getattr(cobj.contents, T.TO._arrayfld)
+                    container = lltype._struct(T.TO, carray.length)
+                else:
+                    # special treatment of 'OBJECT' subclasses
+                    if get_rtyper() and lltype._castdepth(REAL_TYPE, OBJECT) 
>= 0:
+                        # figure out the real type of the object
+                        containerheader = lltype._struct(OBJECT)
+                        cobjheader = ctypes.cast(cobj,
+                                           get_ctypes_type(lltype.Ptr(OBJECT)))
+                        struct_use_ctypes_storage(containerheader,
+                                                  cobjheader)
+                        REAL_TYPE = get_rtyper().get_type_for_typeptr(
+                            containerheader.typeptr)
+                        REAL_T = lltype.Ptr(REAL_TYPE)
+                        cobj = ctypes.cast(cobj, get_ctypes_type(REAL_T))
+                    container = lltype._struct(REAL_TYPE)
+                struct_use_ctypes_storage(container, cobj)
+                if REAL_TYPE != T.TO:
+                    p = container._as_ptr()
+                    container = lltype.cast_pointer(T, p)._as_obj()
+                # special treatment of 'OBJECT_VTABLE' subclasses
+                if get_rtyper() and lltype._castdepth(REAL_TYPE,
+                                                      OBJECT_VTABLE) >= 0:
+                    # figure out the real object that this vtable points to,
+                    # and just return that
+                    p = get_rtyper().get_real_typeptr_for_typeptr(
+                        container._as_ptr())
+                    container = lltype.cast_pointer(T, p)._as_obj()
+            elif isinstance(T.TO, lltype.Array):
+                if T.TO._hints.get('nolength', False):
+                    container = _array_of_unknown_length(T.TO)
+                    container._storage = type(cobj)(cobj.contents)
+                else:
+                    container = _array_of_known_length(T.TO)
+                    container._storage = type(cobj)(cobj.contents)
+            elif isinstance(T.TO, lltype.FuncType):
+                cobjkey = intmask(ctypes.cast(cobj, ctypes.c_void_p).value)
+                if cobjkey in _int2obj:
+                    container = _int2obj[cobjkey]
+                else:
+                    _callable = get_ctypes_trampoline(T.TO, cobj)
+                    return lltype.functionptr(T.TO, getattr(cobj, '__name__', 
'?'),
+                                              _callable=_callable)
+            elif isinstance(T.TO, lltype.OpaqueType):
+                if T == llmemory.GCREF:
+                    container = _llgcopaque(cobj)
+                else:
+                    container = lltype._opaque(T.TO)
+                    cbuf = ctypes.cast(cobj, ctypes.c_void_p)
+                    add_storage(container, _parentable_mixin, cbuf)
             else:
-                # special treatment of 'OBJECT' subclasses
-                if get_rtyper() and lltype._castdepth(REAL_TYPE, OBJECT) >= 0:
-                    # figure out the real type of the object
-                    containerheader = lltype._struct(OBJECT)
-                    cobjheader = ctypes.cast(cobj,
-                                       get_ctypes_type(lltype.Ptr(OBJECT)))
-                    struct_use_ctypes_storage(containerheader,
-                                              cobjheader)
-                    REAL_TYPE = get_rtyper().get_type_for_typeptr(
-                        containerheader.typeptr)
-                    REAL_T = lltype.Ptr(REAL_TYPE)
-                    cobj = ctypes.cast(cobj, get_ctypes_type(REAL_T))
-                container = lltype._struct(REAL_TYPE)
-            struct_use_ctypes_storage(container, cobj)
-            if REAL_TYPE != T.TO:
-                p = container._as_ptr()
-                container = lltype.cast_pointer(T, p)._as_obj()
-            # special treatment of 'OBJECT_VTABLE' subclasses
-            if get_rtyper() and lltype._castdepth(REAL_TYPE,
-                                                  OBJECT_VTABLE) >= 0:
-                # figure out the real object that this vtable points to,
-                # and just return that
-                p = get_rtyper().get_real_typeptr_for_typeptr(
-                    container._as_ptr())
-                container = lltype.cast_pointer(T, p)._as_obj()
-        elif isinstance(T.TO, lltype.Array):
-            if T.TO._hints.get('nolength', False):
-                container = _array_of_unknown_length(T.TO)
-                container._storage = type(cobj)(cobj.contents)
+                raise NotImplementedError(T)
+            llobj = lltype._ptr(T, container, solid=True)
+        elif T is llmemory.Address:
+            if cobj is None:
+                llobj = llmemory.NULL
             else:
-                container = _array_of_known_length(T.TO)
-                container._storage = type(cobj)(cobj.contents)
-        elif isinstance(T.TO, lltype.FuncType):
-            cobjkey = intmask(ctypes.cast(cobj, ctypes.c_void_p).value)
-            if cobjkey in _int2obj:
-                container = _int2obj[cobjkey]
-            else:
-                _callable = get_ctypes_trampoline(T.TO, cobj)
-                return lltype.functionptr(T.TO, getattr(cobj, '__name__', '?'),
-                                          _callable=_callable)
-        elif isinstance(T.TO, lltype.OpaqueType):
-            if T == llmemory.GCREF:
-                container = _llgcopaque(cobj)
-            else:
-                container = lltype._opaque(T.TO)
-                cbuf = ctypes.cast(cobj, ctypes.c_void_p)
-                add_storage(container, _parentable_mixin, cbuf)
-        else:
-            raise NotImplementedError(T)
-        llobj = lltype._ptr(T, container, solid=True)
-    elif T is llmemory.Address:
-        if cobj is None:
-            llobj = llmemory.NULL
-        else:
-            llobj = _lladdress(cobj)
-    elif T is lltype.Char:
-        llobj = chr(cobj)
-    elif T is lltype.UniChar:
-        try:
-            llobj = unichr(cobj)
-        except (ValueError, OverflowError):
-            for tc in 'HIL':
-                if array(tc).itemsize == array('u').itemsize:
-                    import struct
-                    cobj &= 256 ** struct.calcsize(tc) - 1
-                    llobj = array('u', array(tc, (cobj,)).tostring())[0]
-                    break
-            else:
-                raise
-    elif T is lltype.Signed:
-        llobj = cobj
-    elif T is lltype.Bool:
-        assert cobj == True or cobj == False    # 0 and 1 work too
-        llobj = bool(cobj)
-    elif T is lltype.SingleFloat:
-        if isinstance(cobj, ctypes.c_float):
-            cobj = cobj.value
-        llobj = r_singlefloat(cobj)
-    elif T is lltype.LongFloat:
-        if isinstance(cobj, ctypes.c_longdouble):
-            cobj = cobj.value
-        llobj = r_longfloat(cobj)
-    elif T is lltype.Void:
-        llobj = cobj
-    else:
-        from rpython.rtyper.lltypesystem import rffi
-        try:
-            inttype = rffi.platform.numbertype_to_rclass[T]
-        except KeyError:
+                llobj = _lladdress(cobj)
+        elif T is lltype.Char:
+            llobj = chr(cobj)
+        elif T is lltype.UniChar:
+            try:
+                llobj = unichr(cobj)
+            except (ValueError, OverflowError):
+                for tc in 'HIL':
+                    if array(tc).itemsize == array('u').itemsize:
+                        import struct
+                        cobj &= 256 ** struct.calcsize(tc) - 1
+                        llobj = array('u', array(tc, (cobj,)).tostring())[0]
+                        break
+                else:
+                    raise
+        elif T is lltype.Signed:
+            llobj = cobj
+        elif T is lltype.Bool:
+            assert cobj == True or cobj == False    # 0 and 1 work too
+            llobj = bool(cobj)
+        elif T is lltype.SingleFloat:
+            if isinstance(cobj, ctypes.c_float):
+                cobj = cobj.value
+            llobj = r_singlefloat(cobj)
+        elif T is lltype.LongFloat:
+            if isinstance(cobj, ctypes.c_longdouble):
+                cobj = cobj.value
+            llobj = r_longfloat(cobj)
+        elif T is lltype.Void:
             llobj = cobj
         else:
-            llobj = inttype(cobj)
+            from rpython.rtyper.lltypesystem import rffi
+            try:
+                inttype = rffi.platform.numbertype_to_rclass[T]
+            except KeyError:
+                llobj = cobj
+            else:
+                llobj = inttype(cobj)
 
-    assert lltype.typeOf(llobj) == T
-    return llobj
+        assert lltype.typeOf(llobj) == T
+        return llobj
 
 def uninitialized2ctypes(T):
     "For debugging, create a ctypes object filled with 0xDD."
@@ -1244,52 +1244,52 @@
 
 
 def force_cast(RESTYPE, value):
-  with rlock:
-    if not isinstance(RESTYPE, lltype.LowLevelType):
-        raise TypeError("rffi.cast() first arg should be a TYPE")
-    if isinstance(value, llmemory.AddressAsInt):
-        value = value.adr
-    if isinstance(value, llmemory.fakeaddress):
-        value = value.ptr or 0
-    if isinstance(value, r_singlefloat):
-        value = float(value)
-    TYPE1 = lltype.typeOf(value)
-    cvalue = lltype2ctypes(value)
-    cresulttype = get_ctypes_type(RESTYPE)
-    if RESTYPE == TYPE1:
-        return value
-    elif isinstance(TYPE1, lltype.Ptr):
+    with rlock:
+        if not isinstance(RESTYPE, lltype.LowLevelType):
+            raise TypeError("rffi.cast() first arg should be a TYPE")
+        if isinstance(value, llmemory.AddressAsInt):
+            value = value.adr
+        if isinstance(value, llmemory.fakeaddress):
+            value = value.ptr or 0
+        if isinstance(value, r_singlefloat):
+            value = float(value)
+        TYPE1 = lltype.typeOf(value)
+        cvalue = lltype2ctypes(value)
+        cresulttype = get_ctypes_type(RESTYPE)
+        if RESTYPE == TYPE1:
+            return value
+        elif isinstance(TYPE1, lltype.Ptr):
+            if isinstance(RESTYPE, lltype.Ptr):
+                # shortcut: ptr->ptr cast
+                cptr = ctypes.cast(cvalue, cresulttype)
+                return ctypes2lltype(RESTYPE, cptr)
+            # first cast the input pointer to an integer
+            cvalue = ctypes.cast(cvalue, ctypes.c_void_p).value
+            if cvalue is None:
+                cvalue = 0
+        elif isinstance(cvalue, (str, unicode)):
+            cvalue = ord(cvalue)     # character -> integer
+        elif hasattr(RESTYPE, "_type") and issubclass(RESTYPE._type, base_int):
+            cvalue = int(cvalue)
+        elif isinstance(cvalue, r_longfloat):
+            cvalue = cvalue.value
+
+        if not isinstance(cvalue, (int, long, float)):
+            raise NotImplementedError("casting %r to %r" % (TYPE1, RESTYPE))
+
         if isinstance(RESTYPE, lltype.Ptr):
-            # shortcut: ptr->ptr cast
-            cptr = ctypes.cast(cvalue, cresulttype)
-            return ctypes2lltype(RESTYPE, cptr)
-        # first cast the input pointer to an integer
-        cvalue = ctypes.cast(cvalue, ctypes.c_void_p).value
-        if cvalue is None:
-            cvalue = 0
-    elif isinstance(cvalue, (str, unicode)):
-        cvalue = ord(cvalue)     # character -> integer
-    elif hasattr(RESTYPE, "_type") and issubclass(RESTYPE._type, base_int):
-        cvalue = int(cvalue)
-    elif isinstance(cvalue, r_longfloat):
-        cvalue = cvalue.value
-
-    if not isinstance(cvalue, (int, long, float)):
-        raise NotImplementedError("casting %r to %r" % (TYPE1, RESTYPE))
-
-    if isinstance(RESTYPE, lltype.Ptr):
-        # upgrade to a more recent ctypes (e.g. 1.0.2) if you get
-        # an OverflowError on the following line.
-        cvalue = ctypes.cast(ctypes.c_void_p(cvalue), cresulttype)
-    elif RESTYPE == lltype.Bool:
-        cvalue = bool(cvalue)
-    else:
-        try:
-            cvalue = cresulttype(cvalue).value   # mask high bits off if needed
-        except TypeError:
-            cvalue = int(cvalue)   # float -> int
-            cvalue = cresulttype(cvalue).value   # try again
-    return ctypes2lltype(RESTYPE, cvalue)
+            # upgrade to a more recent ctypes (e.g. 1.0.2) if you get
+            # an OverflowError on the following line.
+            cvalue = ctypes.cast(ctypes.c_void_p(cvalue), cresulttype)
+        elif RESTYPE == lltype.Bool:
+            cvalue = bool(cvalue)
+        else:
+            try:
+                cvalue = cresulttype(cvalue).value   # mask high bits off if 
needed
+            except TypeError:
+                cvalue = int(cvalue)   # float -> int
+                cvalue = cresulttype(cvalue).value   # try again
+        return ctypes2lltype(RESTYPE, cvalue)
 
 class ForceCastEntry(ExtRegistryEntry):
     _about_ = force_cast
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py 
b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -580,9 +580,9 @@
         (Unsigned, u"x", ord(u'x')),
     ]
     for TGT, orig_val, expect in cases:
-         res = cast_primitive(TGT, orig_val)
-         assert typeOf(res) == TGT
-         assert res == expect
+        res = cast_primitive(TGT, orig_val)
+        assert typeOf(res) == TGT
+        assert res == expect
     res = cast_primitive(SingleFloat, 2.1)
     assert isinstance(res, r_singlefloat)
     assert float(res) == float(r_singlefloat(2.1))
diff --git a/rpython/translator/goal/order.py b/rpython/translator/goal/order.py
--- a/rpython/translator/goal/order.py
+++ b/rpython/translator/goal/order.py
@@ -9,10 +9,10 @@
 
 lst = open(module_list, 'r')
 try:
-   print "reading module-list: %s" % module_list
-   prefixes = lst.readlines()
+    print "reading module-list: %s" % module_list
+    prefixes = lst.readlines()
 finally:
-   lst.close()
+    lst.close()
 
 prefixes = [line.strip() for line in prefixes]
 prefixes = [line for line in prefixes if line and not line.startswith('#')]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to