* @brief Creates a Python tuple from capabilities mask. * @param[in] caps Capabilities mask * @return New reference to Python tuple, or NULL on error */
| 72 | * @return New reference to Python tuple, or NULL on error |
| 73 | */ |
| 74 | static PyObject *capabilities_to_tuple(sz_capability_t caps) { |
| 75 | char const *cap_strings[SZ_CAPABILITIES_COUNT]; |
| 76 | sz_size_t cap_count = sz_capabilities_to_strings_implementation_(caps, cap_strings, SZ_CAPABILITIES_COUNT); |
| 77 | |
| 78 | PyObject *caps_tuple = PyTuple_New(cap_count); |
| 79 | if (!caps_tuple) return NULL; |
| 80 | |
| 81 | for (sz_size_t i = 0; i < cap_count; i++) { |
| 82 | PyObject *cap_str = PyUnicode_FromString(cap_strings[i]); |
| 83 | if (!cap_str) { |
| 84 | Py_DECREF(caps_tuple); |
| 85 | return NULL; |
| 86 | } |
| 87 | PyTuple_SET_ITEM(caps_tuple, i, cap_str); |
| 88 | } |
| 89 | return caps_tuple; |
| 90 | } |
| 91 | |
| 92 | // Try to import NumPy, and fail if it's not available |
| 93 | static int numpy_available = 0; |
no test coverage detected
searching dependent graphs…