[pypy-svn] r64952 - in pypy/branch/pyjitpl5/pypy: annotation rpython/ootypesystem/test

antocuni at codespeak.net antocuni at codespeak.net
Fri May 1 19:30:48 CEST 2009


Author: antocuni
Date: Fri May  1 19:30:46 2009
New Revision: 64952

Modified:
   pypy/branch/pyjitpl5/pypy/annotation/unaryop.py
   pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
bah, you cannot really call the method with the default value of the
parameters, else it might triggers errors (like an AssertionError inside
ootype._string.ll_stritem_nonneg).  Instead, just trust the value of METH.RESULT



Modified: pypy/branch/pyjitpl5/pypy/annotation/unaryop.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/annotation/unaryop.py	(original)
+++ pypy/branch/pyjitpl5/pypy/annotation/unaryop.py	Fri May  1 19:30:46 2009
@@ -786,9 +786,9 @@
         info = 'argument to ll bound method call'
         llargs = [annotation_to_lltype(s_arg,info)._defl() for s_arg in args_s]
         inst = m.ootype._example()
-        meth = getattr(inst, m.name)
-        v = meth(*llargs)
-        return ll_to_annotation(v)
+        _, meth = ootype.typeOf(inst)._lookup(m.name)
+        METH = ootype.typeOf(meth)
+        return lltype_to_annotation(METH.RESULT)
 
 
 class __extend__(SomeOOStaticMeth):

Modified: pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py	Fri May  1 19:30:46 2009
@@ -439,3 +439,13 @@
 
     res = interpret(fn, [4, 5], type_system='ootype')
     assert res == 3+4+5
+
+def test_boundmeth_callargs_stritem_nonneg():
+    def fn(i):
+        s = ootype.oostring(42, -1)
+        meth = s.ll_stritem_nonneg
+        args = (i,)
+        return meth(*args)
+
+    res = interpret(fn, [0], type_system='ootype')
+    assert res == '4'



More information about the Pypy-commit mailing list