[pypy-commit] pypy stm: Simplify.

arigo noreply at buildbot.pypy.org
Tue Jan 24 16:49:05 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51710:6a0e53c03ecb
Date: 2012-01-23 18:18 +0100
http://bitbucket.org/pypy/pypy/changeset/6a0e53c03ecb/

Log:	Simplify.

diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -352,10 +352,9 @@
                 pass
         return False
 
-    def _immutable_interiorfield(self, fields_v):
+    def _immutable_interiorfield(self, fields):
         T = self
-        for v_field in fields_v:
-            fieldname = getattr(v_field, 'value', None)
+        for fieldname in fields:   # may also be None or an integer, for arrays
             if T._immutable_field(fieldname):
                 return True
             if isinstance(fieldname, str):
diff --git a/pypy/rpython/lltypesystem/test/test_lltype.py b/pypy/rpython/lltypesystem/test/test_lltype.py
--- a/pypy/rpython/lltypesystem/test/test_lltype.py
+++ b/pypy/rpython/lltypesystem/test/test_lltype.py
@@ -805,40 +805,35 @@
     assert S.d._immutable_field() == True
 
 def test_immutable_interiorfield():
-    class Constant:
-        def __init__(self, value):
-            self.value = value
     #
     for hints in [{}, {'immutable': True}]:
         expected = 'immutable' in hints
         #
         T = Struct('T', ('a', lltype.Signed), hints=hints)
         S = GcStruct('S', ('t', T))
-        immut = S._immutable_interiorfield([Constant('t'), Constant('a')])
+        immut = S._immutable_interiorfield(['t', 'a'])
         assert immut == expected
         #
         T = Struct('T', ('a', lltype.Signed))
         S = GcStruct('S', ('t', T), hints=hints)
-        immut = S._immutable_interiorfield([Constant('t'), Constant('a')])
+        immut = S._immutable_interiorfield(['t', 'a'])
         assert immut == expected
         #
         A = Array(lltype.Signed, hints=hints)
         S = GcStruct('S', ('ar', A))
-        immut = S._immutable_interiorfield([Constant('ar'), Constant(4)])
+        immut = S._immutable_interiorfield(['ar', 4])
         assert immut == expected
         #
         T = Struct('T', ('a', lltype.Signed), hints=hints)
         A = Array(T)
         S = GcStruct('S', ('ar', A))
-        immut = S._immutable_interiorfield([Constant('ar'), Constant(4),
-                                            Constant('a')])
+        immut = S._immutable_interiorfield(['ar', 4, 'a'])
         assert immut == expected
         #
         T = Struct('T', ('a', lltype.Signed))
         A = Array(T, hints=hints)
         S = GcStruct('S', ('ar', A))
-        immut = S._immutable_interiorfield([Constant('ar'), Constant(4),
-                                            Constant('a')])
+        immut = S._immutable_interiorfield(['ar', 4, 'a'])
         assert immut == expected
 
 


More information about the pypy-commit mailing list