* Converts a Python sequence into 'count' PyArrayObjects * * seq - Input Python object, usually a tuple but any sequence works. * Must have integral content. * paramname - The name of the parameter that produced 'seq'. * count - How many arrays there should be (errors if it doesn't match). * op - Where the arrays are placed. */
| 917 | * op - Where the arrays are placed. |
| 918 | */ |
| 919 | static int int_sequence_to_arrays(PyObject *seq, |
| 920 | char *paramname, |
| 921 | int count, |
| 922 | PyArrayObject **op |
| 923 | ) |
| 924 | { |
| 925 | int i; |
| 926 | |
| 927 | if (!PySequence_Check(seq) || PySequence_Size(seq) != count) { |
| 928 | PyErr_Format(PyExc_ValueError, |
| 929 | "parameter %s must be a sequence of length %d", |
| 930 | paramname, count); |
| 931 | return -1; |
| 932 | } |
| 933 | |
| 934 | for (i = 0; i < count; ++i) { |
| 935 | PyObject *item = PySequence_GetItem(seq, i); |
| 936 | if (item == NULL) { |
| 937 | goto fail; |
| 938 | } |
| 939 | op[i] = astype_anyint(item); |
| 940 | Py_DECREF(item); |
| 941 | if (op[i] == NULL) { |
| 942 | goto fail; |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | return 0; |
| 947 | |
| 948 | fail: |
| 949 | while (--i >= 0) { |
| 950 | Py_XDECREF(op[i]); |
| 951 | op[i] = NULL; |
| 952 | } |
| 953 | return -1; |
| 954 | } |
| 955 | |
| 956 | /* Inner loop for ravel_multi_index */ |
| 957 | static int |
no test coverage detected