* Simple helper to create a tuple from an array of items. The `make_null_none` * flag means that NULL entries are replaced with None, which is occasionally * useful. */
| 312 | * useful. |
| 313 | */ |
| 314 | static inline PyObject * |
| 315 | PyArray_TupleFromItems(int n, PyObject *const *items, int make_null_none) |
| 316 | { |
| 317 | PyObject *tuple = PyTuple_New(n); |
| 318 | if (tuple == NULL) { |
| 319 | return NULL; |
| 320 | } |
| 321 | for (int i = 0; i < n; i ++) { |
| 322 | PyObject *tmp; |
| 323 | if (!make_null_none || items[i] != NULL) { |
| 324 | tmp = items[i]; |
| 325 | } |
| 326 | else { |
| 327 | tmp = Py_None; |
| 328 | } |
| 329 | Py_INCREF(tmp); |
| 330 | PyTuple_SET_ITEM(tuple, i, tmp); |
| 331 | } |
| 332 | return tuple; |
| 333 | } |
| 334 | |
| 335 | /* |
| 336 | * Returns 0 if the array has rank 0, -1 otherwise. Prints a deprecation |
no outgoing calls
no test coverage detected