Skip to content

Commit 0e1ac83

Browse files
use explicit stginfo lock
1 parent add8289 commit 0e1ac83

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ _ctypes_CType_Type___sizeof___impl(PyObject *self, PyTypeObject *cls)
578578

579579
/*[clinic input]
580580
@getter
581-
@critical_section
582581
_ctypes.CType_Type.__pointer_type__
583582
584583
[clinic start generated code]*/
@@ -596,9 +595,12 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
596595
PyErr_Format(PyExc_TypeError, "%R must have storage info", self);
597596
return NULL;
598597
}
599-
600-
if (info->pointer_type) {
601-
return Py_NewRef(info->pointer_type);
598+
PyObject *pointer_type;
599+
STGINFO_LOCK(info);
600+
pointer_type = Py_XNewRef(info->pointer_type);
601+
STGINFO_UNLOCK();
602+
if (pointer_type) {
603+
return pointer_type;
602604
}
603605

604606
PyErr_Format(PyExc_AttributeError,
@@ -609,7 +611,6 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
609611

610612
/*[clinic input]
611613
@setter
612-
@critical_section
613614
_ctypes.CType_Type.__pointer_type__
614615
615616
[clinic start generated code]*/
@@ -627,8 +628,9 @@ _ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value)
627628
PyErr_Format(PyExc_TypeError, "%R must have storage info", self);
628629
return -1;
629630
}
630-
631+
STGINFO_LOCK(info);
631632
Py_XSETREF(info->pointer_type, Py_XNewRef(value));
633+
STGINFO_UNLOCK();
632634
return 0;
633635
}
634636

0 commit comments

Comments
 (0)