Skip to content

Commit 2ea18e7

Browse files
committed
Fix PyTruffleTuple_SET_ITEM was not stealing
1 parent 4e72581 commit 2ea18e7

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_method.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ def test_methods(self):
6565
PyObject *argTuple = PyTuple_New(nargs);
6666
if (!argTuple)
6767
return NULL;
68-
for (int i = 0; i < nargs; i++)
68+
for (int i = 0; i < nargs; i++) {
69+
Py_INCREF(args[i]);
6970
PyTuple_SET_ITEM(argTuple, i, args[i]);
71+
}
7072
return argTuple;
7173
}
7274
static PyObject* keywordsToDict(PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tuple.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class TestPyTuple(CPyExtTestCase):
166166
Py_DECREF(tuple);
167167
return NULL;
168168
}
169+
Py_INCREF(item);
169170
PyTuple_SET_ITEM(tuple, i, item);
170171
}
171172
Py_INCREF(value);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected static SetItemNode createSetItem() {
158158
}
159159
}
160160

161-
@CApiBuiltin(ret = Void, args = {PyObject, Py_ssize_t, PyObjectBorrowed}, call = Direct)
161+
@CApiBuiltin(ret = Void, args = {PyObject, Py_ssize_t, PyObjectTransfer}, call = Direct)
162162
abstract static class PyTruffleTuple_SET_ITEM extends CApiTernaryBuiltinNode {
163163
@Specialization
164164
static Object doManaged(PTuple tuple, long index, Object element,

0 commit comments

Comments
 (0)