[pypy-svn] r14920 - in pypy/dist/pypy/rpython: . test

arigo at codespeak.net arigo at codespeak.net
Fri Jul 22 17:17:25 CEST 2005


Author: arigo
Date: Fri Jul 22 17:17:23 2005
New Revision: 14920

Modified:
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/rpython/test/test_robject.py
Log:
More special-casing necessary for lists of SomeObjects, to be able to call
their methods (e.g. append()).  Should fix a number of the TyperErrors in
ISSUES.txt.


Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Fri Jul 22 17:17:23 2005
@@ -22,7 +22,11 @@
         else:
             # built-in method case
             assert self.methodname is not None
-            return BuiltinMethodRepr(rtyper, self.s_self, self.methodname)
+            result = BuiltinMethodRepr(rtyper, self.s_self, self.methodname)
+            if result.self_repr == pyobj_repr:
+                return pyobj_repr   # special case: methods of 'PyObject*'
+            else:
+                return result
     def rtyper_makekey(self):
         if self.s_self is None:
             # built-in function case

Modified: pypy/dist/pypy/rpython/test/test_robject.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_robject.py	(original)
+++ pypy/dist/pypy/rpython/test/test_robject.py	Fri Jul 22 17:17:23 2005
@@ -27,8 +27,22 @@
     def f(i, c):
         lis = [1, 2, 3, 4]
         lis[i] = c
+        lis.append(i)
         return len(lis)
-    res = interpret(f, [2, 'c'])#, view=True)
-    assert res == 4
+    res = interpret(f, [2, 'c'])
+    assert res == 5
     res = interpret(f, [3, 'c'])
-    assert res == 4
+    assert res == 5
+
+def inprogress_test_obj_iter():
+    def f(flag):
+        if flag:
+            x = (1, 2)
+        else:
+            x = '34'
+        lst = [u for u in x]
+        return lst[flag]
+    res = interpret(f, [1], view=True)
+    assert res._obj.value == 2
+    res = interpret(f, [0])
+    assert res._obj.value == '3'



More information about the Pypy-commit mailing list