mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
a40c793d06
commit
b479dc561c
2 changed files with 34 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue