Skip to content

Commit ab3af14

Browse files
committed
Fix thread safety issue with cell_set_contents().
1 parent 1f5f2a2 commit ab3af14

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Objects/cellobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ cell_get_contents(PyObject *self, void *closure)
145145
static int
146146
cell_set_contents(PyObject *self, PyObject *obj, void *Py_UNUSED(ignored))
147147
{
148-
PyCellObject *op = _PyCell_CAST(self);
149-
Py_XSETREF(op->ob_ref, Py_XNewRef(obj));
148+
PyCellObject *cell = _PyCell_CAST(self);
149+
Py_XINCREF(obj);
150+
PyCell_SetTakeRef((PyCellObject *)cell, obj);
150151
return 0;
151152
}
152153

0 commit comments

Comments
 (0)