@@ -578,14 +578,13 @@ _ctypes_CType_Type___sizeof___impl(PyObject *self, PyTypeObject *cls)
578
578
579
579
/*[clinic input]
580
580
@getter
581
- @critical_section
582
581
_ctypes.CType_Type.__pointer_type__
583
582
584
583
[clinic start generated code]*/
585
584
586
585
static PyObject *
587
586
_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 ]*/
589
588
{
590
589
ctypes_state * st = get_module_state_by_def (Py_TYPE (self ));
591
590
StgInfo * info ;
@@ -596,9 +595,12 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
596
595
PyErr_Format (PyExc_TypeError , "%R must have storage info" , self );
597
596
return NULL ;
598
597
}
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 ;
602
604
}
603
605
604
606
PyErr_Format (PyExc_AttributeError ,
@@ -609,14 +611,13 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self)
609
611
610
612
/*[clinic input]
611
613
@setter
612
- @critical_section
613
614
_ctypes.CType_Type.__pointer_type__
614
615
615
616
[clinic start generated code]*/
616
617
617
618
static int
618
619
_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 ]*/
620
621
{
621
622
ctypes_state * st = get_module_state_by_def (Py_TYPE (self ));
622
623
StgInfo * info ;
@@ -627,8 +628,9 @@ _ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value)
627
628
PyErr_Format (PyExc_TypeError , "%R must have storage info" , self );
628
629
return -1 ;
629
630
}
630
-
631
+ STGINFO_LOCK ( info );
631
632
Py_XSETREF (info -> pointer_type , Py_XNewRef (value ));
633
+ STGINFO_UNLOCK ();
632
634
return 0 ;
633
635
}
634
636
0 commit comments