@@ -164,14 +164,21 @@ multi_DECREF(PyObject **objects, npy_intp n)
164
164
* > or the newaxis object, but not for integer arrays or other embedded
165
165
* > sequences.
166
166
*
167
+ * The rationale for only unpacking `2*NPY_MAXDIMS` items is the assumption
168
+ * that the longest possible index that is allowed to produce a result is
169
+ * `(0,)*np.MAXDIMS + (None,)*np.MAXDIMS`. This assumption turns out to be
170
+ * wrong (we could add one more item, an Ellipsis), but we keep it for
171
+ * compatibility.
172
+ *
167
173
* @param index The index object, which may or may not be a tuple. This is a
168
174
* borrowed reference.
169
175
* @param result An empty buffer of 2*NPY_MAXDIMS PyObject* to write each
170
- * index component to. The references written are new..
171
- * This function will in some cases clobber the array beyond
172
- * the last item unpacked.
176
+ * index component to. The references written are new.
173
177
*
174
178
* @returns The number of items in `result`, or -1 if an error occured.
179
+ * The entries in `result` at and beyond this index should be
180
+ * assumed to contain garbage, even if they were initialized
181
+ * to NULL, so are not safe to Py_XDECREF.
175
182
*/
176
183
NPY_NO_EXPORT npy_intp
177
184
unpack_indices (PyObject * index , PyObject * result [2 * NPY_MAXDIMS ])
@@ -234,7 +241,9 @@ unpack_indices(PyObject *index, PyObject *result[2*NPY_MAXDIMS])
234
241
235
242
/*
236
243
* At this point, we're left with a non-tuple, non-array, sequence:
237
- * typically, a list
244
+ * typically, a list. We use some somewhat-arbirary heuristics from here
245
+ * onwards to decided whether to treat that list as a single index, or a
246
+ * list of indices. It might be worth deprecating this behaviour (gh-4434).
238
247
*
239
248
* Sequences < NPY_MAXDIMS with any slice objects
240
249
* or newaxis, Ellipsis or other arrays or sequences
0 commit comments