[pypy-svn] r77840 - in pypy/branch/jitffi/pypy/rpython: . test

antocuni at codespeak.net antocuni at codespeak.net
Tue Oct 12 17:08:22 CEST 2010


Author: antocuni
Date: Tue Oct 12 17:08:20 2010
New Revision: 77840

Modified:
   pypy/branch/jitffi/pypy/rpython/rpbc.py
   pypy/branch/jitffi/pypy/rpython/test/test_rclass.py
Log:
(arigo, antocuni): fix this corner case


Modified: pypy/branch/jitffi/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/jitffi/pypy/rpython/rpbc.py	(original)
+++ pypy/branch/jitffi/pypy/rpython/rpbc.py	Tue Oct 12 17:08:20 2010
@@ -256,6 +256,8 @@
     def convert_const(self, value):
         if isinstance(value, types.MethodType) and value.im_self is None:
             value = value.im_func   # unbound method -> bare function
+        elif isinstance(value, staticmethod):
+            value = value.__get__(42) # hackish, get the function wrapped by staticmethod
         if self.lowleveltype is Void:
             return None
         if value is None:

Modified: pypy/branch/jitffi/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/branch/jitffi/pypy/rpython/test/test_rclass.py	(original)
+++ pypy/branch/jitffi/pypy/rpython/test/test_rclass.py	Tue Oct 12 17:08:20 2010
@@ -319,6 +319,17 @@
         res = self.interpret(f, [])
         assert res == 42
 
+    def test_staticmethod2(self):
+        class A(object):
+            f = staticmethod(lambda x, y: x*y)
+        class B(A):
+            f = staticmethod(lambda x, y: x+y)
+        def f():
+            b = B()
+            return b.f(6, 7)
+        res = self.interpret(f, [])
+        assert res == 13
+
     def test_is(self):
         class A: pass
         class B(A): pass



More information about the Pypy-commit mailing list