From 2bcde144ae79c72de05196f7da4ed32396e398d6 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 29 May 2009 04:52:27 +0000 Subject: Issue 5982: Classmethod and staticmethod expose wrapped function with __func__. --- Objects/funcobject.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Objects/funcobject.c') diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 1bb2092d66..acd662cb32 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -775,6 +775,11 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds) return 0; } +static PyMemberDef cm_memberlist[] = { + {"__func__", T_OBJECT, offsetof(classmethod, cm_callable), READONLY}, + {NULL} /* Sentinel */ +}; + PyDoc_STRVAR(classmethod_doc, "classmethod(function) -> method\n\ \n\ @@ -825,7 +830,7 @@ PyTypeObject PyClassMethod_Type = { 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ - 0, /* tp_members */ + cm_memberlist, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ @@ -925,6 +930,11 @@ sm_init(PyObject *self, PyObject *args, PyObject *kwds) return 0; } +static PyMemberDef sm_memberlist[] = { + {"__func__", T_OBJECT, offsetof(staticmethod, sm_callable), READONLY}, + {NULL} /* Sentinel */ +}; + PyDoc_STRVAR(staticmethod_doc, "staticmethod(function) -> method\n\ \n\ @@ -972,7 +982,7 @@ PyTypeObject PyStaticMethod_Type = { 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ - 0, /* tp_members */ + sm_memberlist, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ -- cgit v1.2.1