[pypy-svn] pypy default: fix staticmethod.__new__

cfbolz commits-noreply at bitbucket.org
Tue May 3 13:35:14 CEST 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r43856:2d89c6b23446
Date: 2011-05-03 13:34 +0200
http://bitbucket.org/pypy/pypy/changeset/2d89c6b23446/

Log:	fix staticmethod.__new__

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -600,8 +600,10 @@
         """staticmethod(x).__get__(obj[, type]) -> x"""
         return self.w_function
 
-    def descr_staticmethod__new__(space, w_type, w_function):
-        return space.wrap(StaticMethod(w_function))
+    def descr_staticmethod__new__(space, w_subtype, w_function):
+        instance = space.allocate_instance(StaticMethod, w_subtype)
+        instance.__init__(w_function)
+        return space.wrap(instance)
 
 class ClassMethod(Wrappable):
     """The classmethod objects."""
diff --git a/pypy/module/__builtin__/test/test_descriptor.py b/pypy/module/__builtin__/test/test_descriptor.py
--- a/pypy/module/__builtin__/test/test_descriptor.py
+++ b/pypy/module/__builtin__/test/test_descriptor.py
@@ -17,6 +17,12 @@
         assert d.f("abc", "def") == "abcdef"
         assert D.f("abc", "def") == "abcdef"
 
+    def test_staticmethod(self):
+        class Static(staticmethod):
+            pass
+        x = Static(1)
+        assert isinstance(x, Static)
+
     def test_classmethod(self):
         class C(object):
             def f(cls, stuff):


More information about the Pypy-commit mailing list