Skip to content

Commit

Permalink
BUG: Avoid NpyIter_EnableExternalLoop as it resets the buffer
Browse files Browse the repository at this point in the history
Resetting the buffer will copy it, which may cause casting errors.
And we want to prefer/catch those later ideally.
  • Loading branch information
seberg committed Jun 2, 2022
1 parent 753edc8 commit 68e7803
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2991,6 +2991,11 @@ PyArray_MapIterNew(npy_index_info *indices , int index_num, int index_type,

/* If external array is iterated, and no subspace is needed */
nops = mit->numiter;

if (!uses_subspace) {
outer_flags |= NPY_ITER_EXTERNAL_LOOP;
}

if (extra_op_flags && !uses_subspace) {
/*
* NOTE: This small limitation should practically not matter.
Expand Down Expand Up @@ -3038,9 +3043,6 @@ PyArray_MapIterNew(npy_index_info *indices , int index_num, int index_type,
if (mit->outer == NULL) {
goto fail;
}
if (!uses_subspace) {
NpyIter_EnableExternalLoop(mit->outer);
}

mit->outer_next = NpyIter_GetIterNext(mit->outer, NULL);
if (mit->outer_next == NULL) {
Expand Down

0 comments on commit 68e7803

Please sign in to comment.