]> granicus.if.org Git - python/commitdiff
Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
authorGuido van Rossum <guido@python.org>
Wed, 5 Sep 2001 22:52:50 +0000 (22:52 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 5 Sep 2001 22:52:50 +0000 (22:52 +0000)
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.

Include/classobject.h
Objects/classobject.c

index 3bd535e1c35a581855644637a0876b084b575ea0..3b25c7447d633565bf15c0a122f2f36f441f07a4 100644 (file)
@@ -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) \
index dd2a40b68f5c55cad49b42b4408903a008e4aabb..a38f354b2a1e35ec8a1bb69fb2fc776790caf7e4 100644 (file)
@@ -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)
 {