|
12 | 12 | static PyObject * |
13 | 13 | _types_lookup_special_method_impl(PyObject *self, PyObject *args) |
14 | 14 | { |
15 | | - PyObject *obj, *attr; |
16 | | - if (!PyArg_ParseTuple(args, "OO", &obj, &attr)) { |
17 | | - return NULL; |
18 | | - } |
19 | | - if (!PyUnicode_Check(attr)) { |
20 | | - PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", |
21 | | - Py_TYPE(attr)->tp_name); |
22 | | - return NULL; |
23 | | - } |
24 | | - _PyStackRef method_and_self[2]; |
25 | | - method_and_self[0] = PyStackRef_NULL; |
26 | | - method_and_self[1] = PyStackRef_FromPyObjectBorrow(obj); |
27 | | - int result = _PyObject_LookupSpecialMethod(attr, method_and_self); |
28 | | - if (result == -1) { |
29 | | - return NULL; |
30 | | - } |
31 | | - if (result == 0) { |
32 | | - Py_RETURN_NONE; |
33 | | - } |
34 | | - PyObject *method = PyStackRef_AsPyObjectSteal(method_and_self[0]); |
35 | | - return Py_BuildValue("O", method); |
| 15 | + PyObject *obj, *attr; |
| 16 | + if (!PyArg_ParseTuple(args, "OO", &obj, &attr)) { |
| 17 | + return NULL; |
| 18 | + } |
| 19 | + if (!PyUnicode_Check(attr)) { |
| 20 | + PyErr_Format(PyExc_TypeError, |
| 21 | + "attribute name must be string, not '%.200s'", |
| 22 | + Py_TYPE(attr)->tp_name); |
| 23 | + return NULL; |
| 24 | + } |
| 25 | + _PyStackRef method_and_self[2]; |
| 26 | + method_and_self[0] = PyStackRef_NULL; |
| 27 | + method_and_self[1] = PyStackRef_FromPyObjectBorrow(obj); |
| 28 | + int result = _PyObject_LookupSpecialMethod(attr, method_and_self); |
| 29 | + if (result == -1) { |
| 30 | + return NULL; |
| 31 | + } |
| 32 | + if (result == 0) { |
| 33 | + Py_RETURN_NONE; |
| 34 | + } |
| 35 | + PyObject *method = PyStackRef_AsPyObjectSteal(method_and_self[0]); |
| 36 | + return Py_BuildValue("O", method); |
36 | 37 | } |
37 | 38 |
|
38 | 39 | static int |
|
0 commit comments