@@ -576,8 +576,16 @@ _ctypes_CType_Type___sizeof___impl(PyObject *self, PyTypeObject *cls)
576576 return PyLong_FromSsize_t (size );
577577}
578578
579+ /*[clinic input]
580+ @getter
581+ @critical_section
582+ _ctypes.CType_Type.__pointer_type__
583+
584+ [clinic start generated code]*/
585+
579586static PyObject *
580- ctype_get_pointer_type (PyObject * self , void * Py_UNUSED (ignored ))
587+ _ctypes_CType_Type___pointer_type___get_impl (PyObject * self )
588+ /*[clinic end generated code: output=718c9ff10b2b0012 input=ff7498aa6edf487c]*/
581589{
582590 ctypes_state * st = get_module_state_by_def (Py_TYPE (self ));
583591 StgInfo * info ;
@@ -599,6 +607,17 @@ ctype_get_pointer_type(PyObject *self, void *Py_UNUSED(ignored))
599607 return NULL ;
600608}
601609
610+ /*[clinic input]
611+ @setter
612+ @critical_section
613+ _ctypes.CType_Type.__pointer_type__
614+
615+ [clinic start generated code]*/
616+
617+ static int
618+ _ctypes_CType_Type___pointer_type___set_impl (PyObject * self , PyObject * value )
619+ /*[clinic end generated code: output=6259be8ea21693fa input=9b2dc2400c388982]*/
620+
602621static int
603622ctype_set_pointer_type (PyObject * self , PyObject * tp , void * Py_UNUSED (ignored ))
604623{
@@ -626,8 +645,7 @@ static PyMethodDef ctype_methods[] = {
626645};
627646
628647static PyGetSetDef ctype_getsets [] = {
629- { "__pointer_type__" , ctype_get_pointer_type , ctype_set_pointer_type ,
630- "pointer type" , NULL },
648+ _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF
631649 { NULL , NULL }
632650};
633651
@@ -1254,9 +1272,11 @@ PyCPointerType_SetProto(ctypes_state *st, PyObject *self, StgInfo *stginfo, PyOb
12541272 return -1 ;
12551273 }
12561274 Py_XSETREF (stginfo -> proto , Py_NewRef (proto ));
1275+ STGINFO_LOCK (info );
12571276 if (info -> pointer_type == NULL ) {
12581277 Py_XSETREF (info -> pointer_type , Py_NewRef (self ));
12591278 }
1279+ STGINFO_UNLOCK ();
12601280 return 0 ;
12611281}
12621282
0 commit comments