@@ -578,14 +578,13 @@ _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]*/
585584
586585static PyObject *
587586_ctypes_CType_Type___pointer_type___get_impl (PyObject * self )
588- /*[clinic end generated code: output=718c9ff10b2b0012 input=ff7498aa6edf487c ]*/
587+ /*[clinic end generated code: output=718c9ff10b2b0012 input=ad12dc835943ceb8 ]*/
589588{
590589 ctypes_state * st = get_module_state_by_def (Py_TYPE (self ));
591590 StgInfo * info ;
@@ -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,14 +611,13 @@ _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]*/
616617
617618static int
618619_ctypes_CType_Type___pointer_type___set_impl (PyObject * self , PyObject * value )
619- /*[clinic end generated code: output=6259be8ea21693fa input=9b2dc2400c388982 ]*/
620+ /*[clinic end generated code: output=6259be8ea21693fa input=a05055fc7f4714b6 ]*/
620621{
621622 ctypes_state * st = get_module_state_by_def (Py_TYPE (self ));
622623 StgInfo * info ;
@@ -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