* PyArray_LookupSpecial_OnInstance: * * Implements incorrect special method lookup rules, that break the python * convention, and looks on the instance, not the type. * * Kept for backwards compatibility. In future, we should deprecate this. */
| 74 | * Kept for backwards compatibility. In future, we should deprecate this. |
| 75 | */ |
| 76 | static inline PyObject * |
| 77 | PyArray_LookupSpecial_OnInstance(PyObject *obj, PyObject *name_unicode) |
| 78 | { |
| 79 | PyTypeObject *tp = Py_TYPE(obj); |
| 80 | |
| 81 | /* We do not need to check for special attributes on trivial types */ |
| 82 | if (_is_basic_python_type(tp)) { |
| 83 | return NULL; |
| 84 | } |
| 85 | |
| 86 | PyObject *res = PyObject_GetAttr(obj, name_unicode); |
| 87 | |
| 88 | if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { |
| 89 | PyErr_Clear(); |
| 90 | } |
| 91 | |
| 92 | return res; |
| 93 | } |
| 94 | |
| 95 | #endif /* NUMPY_CORE_SRC_COMMON_GET_ATTR_STRING_H_ */ |
no test coverage detected