@@ -243,7 +243,7 @@ _pack_legacy_size(CFieldObject *field)
243243}
244244
245245static 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,6 +265,16 @@ 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+
268278static PyObject *
269279PyCField_get (PyObject * op , PyObject * inst , PyObject * type )
270280{
@@ -280,9 +290,13 @@ PyCField_get(PyObject *op, PyObject *inst, PyObject *type)
280290 return NULL ;
281291 }
282292 src = _CDataObject_CAST (inst );
283- return PyCData_get (st , self -> proto , self -> getfunc , inst ,
293+ PyObject * res ;
294+ Py_BEGIN_CRITICAL_SECTION (inst );
295+ res = PyCData_get (st , self -> proto , self -> getfunc , inst ,
284296 self -> index , _pack_legacy_size (self ),
285297 src -> b_ptr + self -> byte_offset );
298+ Py_END_CRITICAL_SECTION ();
299+ return res ;
286300}
287301
288302static PyObject *
0 commit comments