summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/classobject.h4
-rw-r--r--Objects/classobject.c30
2 files changed, 34 insertions, 0 deletions
diff --git a/Include/classobject.h b/Include/classobject.h
index 3bd535e..3b25c74 100644
--- a/Include/classobject.h
+++ b/Include/classobject.h
@@ -47,6 +47,10 @@ extern DL_IMPORT(PyObject *) PyInstance_New(PyObject *, PyObject *,
extern DL_IMPORT(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
+extern DL_IMPORT(PyObject *) PyMethod_Function(PyObject *);
+extern DL_IMPORT(PyObject *) PyMethod_Self(PyObject *);
+extern DL_IMPORT(PyObject *) PyMethod_Class(PyObject *);
+
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyMethod_GET_FUNCTION(meth) \
diff --git a/Objects/classobject.c b/Objects/classobject.c
index dd2a40b..a38f354 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -106,6 +106,36 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name)
return (PyObject *) op;
}
+PyObject *
+PyMethod_Function(PyObject *im)
+{
+ if (!PyMethod_Check(im)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ return ((PyMethodObject *)im)->im_func;
+}
+
+PyObject *
+PyMethod_Self(PyObject *im)
+{
+ if (!PyMethod_Check(im)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ return ((PyMethodObject *)im)->im_self;
+}
+
+PyObject *
+PyMethod_Class(PyObject *im)
+{
+ if (!PyMethod_Check(im)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ return ((PyMethodObject *)im)->im_class;
+}
+
static PyObject *
class_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{