mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
#3247: Get rid of Py_FindMethod:
Second step: keep tp_getattr functions when they are complex, but use PyObject_GenericGetAttr() as a fallback. These were the last occurrences of Py_FindMethod.
This commit is contained in:
parent
e43d33a4db
commit
ba4105c133
4 changed files with 99 additions and 89 deletions
|
@ -280,43 +280,6 @@ PyTypeObject PyCFunction_Type = {
|
|||
0, /* tp_dict */
|
||||
};
|
||||
|
||||
/* Find a method in a method chain */
|
||||
|
||||
PyObject *
|
||||
Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name)
|
||||
{
|
||||
if (name[0] == '_' && name[1] == '_') {
|
||||
if (strcmp(name, "__doc__") == 0) {
|
||||
const char *doc = self->ob_type->tp_doc;
|
||||
if (doc != NULL)
|
||||
return PyUnicode_FromString(doc);
|
||||
}
|
||||
}
|
||||
while (chain != NULL) {
|
||||
PyMethodDef *ml = chain->methods;
|
||||
for (; ml->ml_name != NULL; ml++) {
|
||||
if (name[0] == ml->ml_name[0] &&
|
||||
strcmp(name+1, ml->ml_name+1) == 0)
|
||||
/* XXX */
|
||||
return PyCFunction_New(ml, self);
|
||||
}
|
||||
chain = chain->link;
|
||||
}
|
||||
PyErr_SetString(PyExc_AttributeError, name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find a method in a single method list */
|
||||
|
||||
PyObject *
|
||||
Py_FindMethod(PyMethodDef *methods, PyObject *self, const char *name)
|
||||
{
|
||||
PyMethodChain chain;
|
||||
chain.methods = methods;
|
||||
chain.link = NULL;
|
||||
return Py_FindMethodInChain(&chain, self, name);
|
||||
}
|
||||
|
||||
/* Clear out the free list */
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue