| 31 | } |
| 32 | |
| 33 | inline object try_get_cpp_conduit_method(PyObject *obj) { |
| 34 | if (PyType_Check(obj)) { |
| 35 | return object(); |
| 36 | } |
| 37 | PyTypeObject *type_obj = Py_TYPE(obj); |
| 38 | str attr_name("_pybind11_conduit_v1_"); |
| 39 | bool assumed_to_be_callable = false; |
| 40 | if (type_is_managed_by_our_internals(type_obj)) { |
| 41 | if (!is_instance_method_of_type(type_obj, attr_name.ptr())) { |
| 42 | return object(); |
| 43 | } |
| 44 | assumed_to_be_callable = true; |
| 45 | } |
| 46 | PyObject *method = PyObject_GetAttr(obj, attr_name.ptr()); |
| 47 | if (method == nullptr) { |
| 48 | PyErr_Clear(); |
| 49 | return object(); |
| 50 | } |
| 51 | if (!assumed_to_be_callable && PyCallable_Check(method) == 0) { |
| 52 | Py_DECREF(method); |
| 53 | return object(); |
| 54 | } |
| 55 | return reinterpret_steal<object>(method); |
| 56 | } |
| 57 | |
| 58 | inline void *try_raw_pointer_ephemeral_from_cpp_conduit(handle src, |
| 59 | const std::type_info *cpp_type_info) { |
no test coverage detected