Skip to content

Commit 349a598

Browse files
Added region check to tuple object (#46)
As far as I can see in the source code, tuples are always created in the local region (effectively), and get their arguments before they are assigned anywhere. So the only check added to set_item should always succeed. Leaving optimising this case for future work.
1 parent da00da6 commit 349a598

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Objects/tupleobject.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
124124
return -1;
125125
}
126126

127+
// TODO: Pyrona: Possibly optimise this case as tuples
128+
// should always be in local when they are assigned.
129+
if (!Py_REGIONADDREFERENCE(op, newitem)){
130+
Py_XDECREF(newitem);
131+
// Error set by region add test
132+
return -1;
133+
}
134+
127135
if (i < 0 || i >= Py_SIZE(op)) {
128136
Py_XDECREF(newitem);
129137
PyErr_SetString(PyExc_IndexError,

0 commit comments

Comments
 (0)