|
8 | 8 | #include "pycore_unionobject.h" // _PyUnion_Type |
9 | 9 | #include "pycore_typeobject.h" // _PyObject_LookupSpecialMethod |
10 | 10 | #include "pycore_stackref.h" // _PyStackRef |
| 11 | +#include "clinic/_typesmodule.c.h" |
| 12 | + |
| 13 | +/*[clinic input] |
| 14 | +module _types |
| 15 | +[clinic start generated code]*/ |
| 16 | +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=530308b1011b659d]*/ |
| 17 | + |
| 18 | +/*[clinic input] |
| 19 | +_types.lookup_special_method |
| 20 | +
|
| 21 | + obj: 'O' |
| 22 | + attr: 'O' |
| 23 | + / |
| 24 | +
|
| 25 | +Lookup special method name `attr` on `obj`. |
| 26 | +
|
| 27 | +Lookup method `attr` on `obj` without looking in the instance dictionary. |
| 28 | +Returns `None` if the method is not found. |
| 29 | +[clinic start generated code]*/ |
11 | 30 |
|
12 | 31 | static PyObject * |
13 | | -_types_lookup_special_method_impl(PyObject *self, PyObject *args) |
| 32 | +_types_lookup_special_method_impl(PyObject *module, PyObject *obj, |
| 33 | + PyObject *attr) |
| 34 | +/*[clinic end generated code: output=890e22cc0b8e0d34 input=f26012b0c90b81cd]*/ |
14 | 35 | { |
15 | | - PyObject *obj, *attr; |
16 | | - if (!PyArg_ParseTuple(args, "OO", &obj, &attr)) { |
17 | | - return NULL; |
18 | | - } |
19 | 36 | if (!PyUnicode_Check(attr)) { |
20 | 37 | PyErr_Format(PyExc_TypeError, |
21 | 38 | "attribute name must be string, not '%.200s'", |
@@ -90,11 +107,9 @@ static struct PyModuleDef_Slot _typesmodule_slots[] = { |
90 | 107 | }; |
91 | 108 |
|
92 | 109 | static PyMethodDef _typesmodule_methods[] = { |
93 | | - {"lookup_special_method", _types_lookup_special_method_impl, METH_VARARGS, |
94 | | - "lookup_special_method(obj, attr, /)\n--\n\n" |
95 | | - "Do a method lookup in the type without looking in the instance " |
96 | | - "dictionary. Returns None if the method is not found."}, |
97 | | - {NULL, NULL, 0, NULL}}; |
| 110 | + _TYPES_LOOKUP_SPECIAL_METHOD_METHODDEF |
| 111 | + {NULL, NULL, 0, NULL} |
| 112 | +}; |
98 | 113 |
|
99 | 114 | static struct PyModuleDef typesmodule = { |
100 | 115 | .m_base = PyModuleDef_HEAD_INIT, |
|
0 commit comments