* Convert the array to a scalar if allowed, and apply the builtin function * to it. The where argument is passed onto Py_EnterRecursiveCall when the * array contains python objects. */
| 865 | * array contains python objects. |
| 866 | */ |
| 867 | NPY_NO_EXPORT PyObject * |
| 868 | array_scalar_forward(PyArrayObject *v, |
| 869 | PyObject *(*builtin_func)(PyObject *), |
| 870 | const char *where) |
| 871 | { |
| 872 | if (check_is_convertible_to_scalar(v) < 0) { |
| 873 | return NULL; |
| 874 | } |
| 875 | |
| 876 | PyObject *scalar; |
| 877 | scalar = PyArray_GETITEM(v, PyArray_DATA(v)); |
| 878 | if (scalar == NULL) { |
| 879 | return NULL; |
| 880 | } |
| 881 | |
| 882 | /* Need to guard against recursion if our array holds references */ |
| 883 | if (PyDataType_REFCHK(PyArray_DESCR(v))) { |
| 884 | PyObject *res; |
| 885 | if (Py_EnterRecursiveCall(where) != 0) { |
| 886 | Py_DECREF(scalar); |
| 887 | return NULL; |
| 888 | } |
| 889 | res = builtin_func(scalar); |
| 890 | Py_DECREF(scalar); |
| 891 | Py_LeaveRecursiveCall(); |
| 892 | return res; |
| 893 | } |
| 894 | else { |
| 895 | PyObject *res; |
| 896 | res = builtin_func(scalar); |
| 897 | Py_DECREF(scalar); |
| 898 | return res; |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | |
| 903 | NPY_NO_EXPORT PyObject * |
no test coverage detected