summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-05 22:52:50 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-05 22:52:50 (GMT)
commitb479dc561c1e778c892f04d1e9673400e95d7e78 (patch)
treef34c39cbecffdf0c0cda704a44c8758d6e097f1a /Objects/classobject.c
parenta40c793d06ee2b42a5013015352616b4ca6b288b (diff)
downloadcpython-b479dc561c1e778c892f04d1e9673400e95d7e78.zip
cpython-b479dc561c1e778c892f04d1e9673400e95d7e78.tar.gz
cpython-b479dc561c1e778c892f04d1e9673400e95d7e78.tar.bz2
Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
While not even documented, they were clearly part of the C API, there's no great difficulty to support them, and it has the cool effect of not requiring any changes to ExtensionClass.c.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c30
1 files changed, 30 insertions, 0 deletions
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)
{