Skip to content

Commit 44ec7f2

Browse files
fix arrays
1 parent 362d07a commit 44ec7f2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Modules/_ctypes/cfield.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ _pack_legacy_size(CFieldObject *field)
243243
}
244244

245245
static int
246-
PyCField_set(PyObject *op, PyObject *inst, PyObject *value)
246+
PyCField_set_lock_held(PyObject *op, PyObject *inst, PyObject *value)
247247
{
248248
CDataObject *dst;
249249
char *ptr;
@@ -265,8 +265,18 @@ PyCField_set(PyObject *op, PyObject *inst, PyObject *value)
265265
self->index, _pack_legacy_size(self), ptr);
266266
}
267267

268+
static int
269+
PyCField_set(PyObject *op, PyObject *inst, PyObject *value)
270+
{
271+
int res;
272+
Py_BEGIN_CRITICAL_SECTION(inst);
273+
res = PyCField_set_lock_held(op, inst, value);
274+
Py_END_CRITICAL_SECTION();
275+
return res;
276+
}
277+
268278
static PyObject *
269-
PyCField_get(PyObject *op, PyObject *inst, PyObject *type)
279+
PyCField_get_lock_held(PyObject *op, PyObject *inst, PyObject *type)
270280
{
271281
CDataObject *src;
272282
CFieldObject *self = _CFieldObject_CAST(op);
@@ -285,6 +295,16 @@ PyCField_get(PyObject *op, PyObject *inst, PyObject *type)
285295
src->b_ptr + self->byte_offset);
286296
}
287297

298+
static PyObject *
299+
PyCField_get(PyObject *op, PyObject *inst, PyObject *type)
300+
{
301+
PyObject *res;
302+
Py_BEGIN_CRITICAL_SECTION(inst);
303+
res = PyCField_get_lock_held(op, inst, type);
304+
Py_END_CRITICAL_SECTION();
305+
return res;
306+
}
307+
288308
static PyObject *
289309
PyCField_get_legacy_size(PyObject *self, void *Py_UNUSED(closure))
290310
{

0 commit comments

Comments
 (0)