* Lookup a special method, following the python approach of looking up * on the type object, rather than on the instance itself. * * Assumes that the special method is a numpy-specific one, so does not look * at builtin types. It does check base ndarray and numpy scalar types. * * In future, could be made more like _Py_LookupSpecial */
| 47 | * In future, could be made more like _Py_LookupSpecial |
| 48 | */ |
| 49 | static inline PyObject * |
| 50 | PyArray_LookupSpecial(PyObject *obj, PyObject *name_unicode) |
| 51 | { |
| 52 | PyTypeObject *tp = Py_TYPE(obj); |
| 53 | |
| 54 | /* We do not need to check for special attributes on trivial types */ |
| 55 | if (_is_basic_python_type(tp)) { |
| 56 | return NULL; |
| 57 | } |
| 58 | PyObject *res = PyObject_GetAttr((PyObject *)tp, name_unicode); |
| 59 | |
| 60 | if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { |
| 61 | PyErr_Clear(); |
| 62 | } |
| 63 | |
| 64 | return res; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /* |
no test coverage detected