[pypy-svn] pypy fast-forward: Add classmethod.__func__, staticmethod.__func__

amauryfa commits-noreply at bitbucket.org
Fri Jan 14 08:48:39 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40658:8da3f3c551c9
Date: 2011-01-14 08:48 +0100
http://bitbucket.org/pypy/pypy/changeset/8da3f3c551c9/

Log:	Add classmethod.__func__, staticmethod.__func__

diff --git a/pypy/interpreter/test/test_function.py b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -36,6 +36,12 @@
         assert f.__defaults__ is f.func_defaults
         assert hasattr(f, '__class__')
 
+    def test_classmethod(self):
+        def f():
+            pass
+        assert classmethod(f).__func__ is f
+        assert staticmethod(f).__func__ is f
+
     def test_write_doc(self):
         def f(): "hello"
         assert f.__doc__ == 'hello'

diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -819,6 +819,7 @@
     __get__ = interp2app(StaticMethod.descr_staticmethod_get),
     __new__ = interp2app(StaticMethod.descr_staticmethod__new__.im_func,
                          unwrap_spec = [ObjSpace, W_Root, W_Root]),
+    __func__= interp_attrproperty_w('w_function', cls=StaticMethod),
     )
 
 ClassMethod.typedef = TypeDef(
@@ -827,6 +828,7 @@
                          unwrap_spec = [ObjSpace, W_Root, W_Root]),
     __get__ = interp2app(ClassMethod.descr_classmethod_get,
                          unwrap_spec = ['self', ObjSpace, W_Root, W_Root]),
+    __func__= interp_attrproperty_w('w_function', cls=ClassMethod),
     __doc__ = """classmethod(function) -> class method
 
 Convert a function to be a class method.


More information about the Pypy-commit mailing list