Kaydet (Commit) b479dc56 authored tarafından Guido van Rossum's avatar Guido van Rossum

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.
üst a40c793d
......@@ -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) \
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment