* returns 1 if array is a user-defined string dtype, sets an error and * returns 0 otherwise */
| 3925 | * returns 0 otherwise |
| 3926 | */ |
| 3927 | static int _is_user_defined_string_array(PyArrayObject* array) |
| 3928 | { |
| 3929 | if (NPY_DT_is_user_defined(PyArray_DESCR(array))) { |
| 3930 | PyTypeObject* scalar_type = NPY_DTYPE(PyArray_DESCR(array))->scalar_type; |
| 3931 | if (PyType_IsSubtype(scalar_type, &PyBytes_Type) || |
| 3932 | PyType_IsSubtype(scalar_type, &PyUnicode_Type)) { |
| 3933 | return 1; |
| 3934 | } |
| 3935 | else { |
| 3936 | PyErr_SetString( |
| 3937 | PyExc_TypeError, |
| 3938 | "string comparisons are only allowed for dtypes with a " |
| 3939 | "scalar type that is a subtype of str or bytes."); |
| 3940 | return 0; |
| 3941 | } |
| 3942 | } |
| 3943 | else { |
| 3944 | PyErr_SetString( |
| 3945 | PyExc_TypeError, |
| 3946 | "string operation on non-string array"); |
| 3947 | return 0; |
| 3948 | } |
| 3949 | } |
| 3950 | |
| 3951 | |
| 3952 | /* |
no test coverage detected