@@ -133,8 +133,10 @@ bytes(cdata)
133133/*[clinic input]
134134module _ctypes
135135class _ctypes.CFuncPtr "PyCFuncPtrObject *" "&PyCFuncPtr_Type"
136+ class _ctypes.Array "CDataObject *" "clinic_state()->PyCArray_Type"
137+ class _ctypes.Pointer "CDataObject *" "clinic_state()->PyCPointer_Type"
136138[clinic start generated code]*/
137- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=58e8c99474bc631e ]*/
139+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=56de8bab30675d93 ]*/
138140
139141#define clinic_state () (get_module_state_by_class(cls))
140142#define clinic_state_sub () (get_module_state_by_class(cls->tp_base))
@@ -5023,8 +5025,17 @@ Array_init(PyObject *self, PyObject *args, PyObject *kw)
50235025 return 0 ;
50245026}
50255027
5028+ /*[clinic input]
5029+ @critical_section
5030+ _ctypes.Array.__getitem__ as Array_item
5031+ self as myself: self(type="PyObject *")
5032+ index: Py_ssize_t
5033+ /
5034+ [clinic start generated code]*/
5035+
50265036static PyObject *
5027- Array_item_lock_held (PyObject * myself , Py_ssize_t index )
5037+ Array_item_impl (PyObject * myself , Py_ssize_t index )
5038+ /*[clinic end generated code: output=d038162d727d7d9b input=5979a1200a1397ca]*/
50285039{
50295040 _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (myself );
50305041
@@ -5053,18 +5064,17 @@ Array_item_lock_held(PyObject *myself, Py_ssize_t index)
50535064 index , size , self -> b_ptr + offset );
50545065}
50555066
5056- static PyObject *
5057- Array_item (PyObject * myself , Py_ssize_t index )
5058- {
5059- PyObject * result ;
5060- Py_BEGIN_CRITICAL_SECTION (myself );
5061- result = Array_item_lock_held (myself , index );
5062- Py_END_CRITICAL_SECTION ();
5063- return result ;
5064- }
5067+ /*[clinic input]
5068+ @critical_section
5069+ _ctypes.Array.__getitem__ as Array_subscript
5070+ self as myself: self(type="PyObject *")
5071+ item: object
5072+ /
5073+ [clinic start generated code]*/
50655074
50665075static PyObject *
5067- Array_subscript_lock_held (PyObject * myself , PyObject * item )
5076+ Array_subscript_impl (PyObject * myself , PyObject * item )
5077+ /*[clinic end generated code: output=5c88d612ad5c8a1a input=1a68b5a5ba349556]*/
50685078{
50695079 _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (myself );
50705080
@@ -5077,7 +5087,7 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item)
50775087 return NULL ;
50785088 if (i < 0 )
50795089 i += self -> b_length ;
5080- return Array_item_lock_held (myself , i );
5090+ return Array_item_impl (myself , i );
50815091 }
50825092 else if (PySlice_Check (item )) {
50835093 PyObject * proto ;
@@ -5165,7 +5175,7 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item)
51655175
51665176 for (cur = start , i = 0 ; i < slicelen ;
51675177 cur += step , i ++ ) {
5168- PyObject * v = Array_item_lock_held (myself , cur );
5178+ PyObject * v = Array_item_impl (myself , cur );
51695179 if (v == NULL ) {
51705180 Py_DECREF (np );
51715181 return NULL ;
@@ -5182,16 +5192,6 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item)
51825192}
51835193
51845194
5185- static PyObject *
5186- Array_subscript (PyObject * myself , PyObject * item )
5187- {
5188- PyObject * result ;
5189- Py_BEGIN_CRITICAL_SECTION (myself );
5190- result = Array_subscript_lock_held (myself , item );
5191- Py_END_CRITICAL_SECTION ();
5192- return result ;
5193- }
5194-
51955195static int
51965196Array_ass_item_lock_held (PyObject * myself , Py_ssize_t index , PyObject * value )
51975197{
@@ -5574,8 +5574,17 @@ static PyType_Spec pycsimple_spec = {
55745574/*
55755575 PyCPointer_Type
55765576*/
5577+ /*[clinic input]
5578+ @critical_section
5579+ _ctypes.Pointer.__getitem__ as Pointer_item
5580+ self as myself: self(type="PyObject *")
5581+ index: Py_ssize_t
5582+ /
5583+ [clinic start generated code]*/
5584+
55775585static PyObject *
5578- Pointer_item_lock_held (PyObject * myself , Py_ssize_t index )
5586+ Pointer_item_impl (PyObject * myself , Py_ssize_t index )
5587+ /*[clinic end generated code: output=4ae9d566e8038853 input=5e1c027271cdbb9f]*/
55795588{
55805589 CDataObject * self = _CDataObject_CAST (myself );
55815590 _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
@@ -5614,16 +5623,6 @@ Pointer_item_lock_held(PyObject *myself, Py_ssize_t index)
56145623 index , size , (char * )((char * )deref + offset ));
56155624}
56165625
5617- static PyObject *
5618- Pointer_item (PyObject * self , Py_ssize_t index )
5619- {
5620- PyObject * res ;
5621- Py_BEGIN_CRITICAL_SECTION (self );
5622- res = Pointer_item_lock_held (self , index );
5623- Py_END_CRITICAL_SECTION ();
5624- return res ;
5625- }
5626-
56275626static int
56285627Pointer_ass_item_lock_held (PyObject * myself , Py_ssize_t index , PyObject * value )
56295628{
@@ -5815,7 +5814,7 @@ copy_pointer_to_list_lock_held(PyObject *myself, PyObject *np, Py_ssize_t len,
58155814 Py_ssize_t i ;
58165815 size_t cur ;
58175816 for (cur = start , i = 0 ; i < len ; cur += step , i ++ ) {
5818- PyObject * v = Pointer_item_lock_held (myself , cur );
5817+ PyObject * v = Pointer_item_impl (myself , cur );
58195818 if (!v ) {
58205819 return -1 ;
58215820 }
0 commit comments