Returns 1 if `o` is an instance of attrs-decorated class. Returns 0 otherwise.
| 234 | // Returns 1 if `o` is an instance of attrs-decorated class. |
| 235 | // Returns 0 otherwise. |
| 236 | int IsAttrsHelper(PyObject* o) { |
| 237 | static auto* const check_cache = new CachedTypeCheck([](PyObject* to_check) { |
| 238 | Safe_PyObjectPtr cls(PyObject_GetAttrString(to_check, "__class__")); |
| 239 | if (cls) { |
| 240 | return PyObject_HasAttrString(cls.get(), "__attrs_attrs__"); |
| 241 | } |
| 242 | |
| 243 | // PyObject_GetAttrString returns null on error |
| 244 | PyErr_Clear(); |
| 245 | return 0; |
| 246 | }); |
| 247 | return check_cache->CachedLookup(o); |
| 248 | } |
| 249 | |
| 250 | // Returns 1 if `o` is an object of type IndexedSlices. |
| 251 | // Returns 0 otherwise. |
no test coverage detected