8000 BUG: cannot modify tuple after use by mattip · Pull Request #7965 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: cannot modify tuple after use #7965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions numpy/core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,6 @@ _vec_string_with_args(PyArrayObject* char_array, PyArray_Descr* type,
PyArrayMultiIterObject* in_iter = NULL;
PyArrayObject* result = NULL;
PyArrayIterObject* out_iter = NULL;
PyObject* args_tuple = NULL;
Py_ssize_t i, n, nargs;

nargs = PySequence_Size(args) + 1;
Expand Down Expand Up @@ -3672,25 +3671,26 @@ _vec_string_with_args(PyArrayObject* char_array, PyArray_Descr* type,
goto err;
}

args_tuple = PyTuple_New(n);
if (args_tuple == NULL) {
goto err;
}

while (PyArray_MultiIter_NOTDONE(in_iter)) {
PyObject* item_result;
PyObject* args_tuple = PyTuple_New(n);
if (args_tuple == NULL) {
goto err;
}

for (i = 0; i < n; i++) {
PyArrayIterObject* it = in_iter->iters[i];
PyObject* arg = PyArray_ToScalar(PyArray_ITER_DATA(it), it->ao);
if (arg == NULL) {
Py_DECREF(args_tuple);
goto err;
}
/* Steals ref to arg */
PyTuple_SetItem(args_tuple, i, arg);
}

item_result = PyObject_CallObject(method, args_tuple);
Py_DECREF(args_tuple);
if (item_result == NULL) {
goto err;
}
Expand All @@ -3709,14 +3709,12 @@ _vec_string_with_args(PyArrayObject* char_array, PyArray_Descr* type,

Py_DECREF(in_iter);
Py_DECREF(out_iter);
Py_DECREF(args_tuple);

return (PyObject*)result;

err:
Py_XDECREF(in_iter);
Py_XDECREF(out_iter);
Py_XDECREF(args_tuple);
Py_XDECREF(result);

return 0;
Expand Down
0