@@ -595,8 +595,14 @@ PyType_Spec pyctype_type_spec = {
595
595
.slots = ctype_type_slots ,
596
596
};
597
597
598
+ /*
599
+ PyCStructType_Type - a meta type/class. Creating a new class using this one as
600
+ __metaclass__ will call the constructor StructUnionType_new.
601
+ It initializes the C accessible fields somehow.
602
+ */
603
+
598
604
static PyCArgObject *
599
- StructUnionType_paramfunc_lock_held (ctypes_state * st , CDataObject * self )
605
+ StructUnionType_paramfunc (ctypes_state * st , CDataObject * self )
600
606
{
601
607
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
602
608
PyCArgObject * parg ;
@@ -649,20 +655,6 @@ StructUnionType_paramfunc_lock_held(ctypes_state *st, CDataObject *self)
649
655
return parg ;
650
656
}
651
657
652
- /*
653
- PyCStructType_Type - a meta type/class. Creating a new class using this one as
654
- __metaclass__ will call the constructor StructUnionType_new.
655
- It initializes the C accessible fields somehow.
656
- */
657
- static PyCArgObject *
658
- StructUnionType_paramfunc (ctypes_state * st , CDataObject * self )
659
- {
660
- PyCArgObject * res ;
661
- Py_BEGIN_CRITICAL_SECTION (self );
662
- res = StructUnionType_paramfunc_lock_held (st , self );
663
- Py_END_CRITICAL_SECTION ();
664
- return res ;
665
- }
666
658
667
659
static int
668
660
StructUnionType_init (PyObject * self , PyObject * args , PyObject * kwds , int isStruct )
@@ -1213,6 +1205,7 @@ PyCPointerType_SetProto(ctypes_state *st, StgInfo *stginfo, PyObject *proto)
1213
1205
static PyCArgObject *
1214
1206
PyCPointerType_paramfunc (ctypes_state * st , CDataObject * self )
1215
1207
{
1208
+ _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
1216
1209
PyCArgObject * parg ;
1217
1210
1218
1211
parg = PyCArgObject_new (st );
@@ -1222,7 +1215,7 @@ PyCPointerType_paramfunc(ctypes_state *st, CDataObject *self)
1222
1215
parg -> tag = 'P' ;
1223
1216
parg -> pffi_type = & ffi_type_pointer ;
1224
1217
parg -> obj = Py_NewRef (self );
1225
- parg -> value .p = locked_deref ( self ) ;
1218
+ parg -> value .p = * ( void * * ) self -> b_ptr ;
1226
1219
return parg ;
1227
1220
}
1228
1221
@@ -1665,6 +1658,7 @@ add_getset(PyTypeObject *type, PyGetSetDef *gsp)
1665
1658
static PyCArgObject *
1666
1659
PyCArrayType_paramfunc (ctypes_state * st , CDataObject * self )
1667
1660
{
1661
+ _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
1668
1662
PyCArgObject * p = PyCArgObject_new (st );
1669
1663
if (p == NULL )
1670
1664
return NULL ;
@@ -2159,7 +2153,9 @@ c_void_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
2159
2153
parg -> tag = 'Z' ;
2160
2154
parg -> obj = Py_NewRef (value );
2161
2155
/* Remember: b_ptr points to where the pointer is stored! */
2162
- parg -> value .p = locked_deref ((CDataObject * )value );
2156
+ Py_BEGIN_CRITICAL_SECTION (value );
2157
+ parg -> value .p = * (void * * )_CDataObject_CAST (value )-> b_ptr ;
2158
+ Py_END_CRITICAL_SECTION ();
2163
2159
return (PyObject * )parg ;
2164
2160
}
2165
2161
}
@@ -2241,7 +2237,7 @@ static PyObject *CreateSwappedType(ctypes_state *st, PyTypeObject *type,
2241
2237
}
2242
2238
2243
2239
static PyCArgObject *
2244
- PyCSimpleType_paramfunc_lock_held (ctypes_state * st , CDataObject * self )
2240
+ PyCSimpleType_paramfunc (ctypes_state * st , CDataObject * self )
2245
2241
{
2246
2242
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
2247
2243
const char * fmt ;
@@ -2270,15 +2266,6 @@ PyCSimpleType_paramfunc_lock_held(ctypes_state *st, CDataObject *self)
2270
2266
return parg ;
2271
2267
}
2272
2268
2273
- static PyCArgObject *
2274
- PyCSimpleType_paramfunc (ctypes_state * st , CDataObject * self )
2275
- {
2276
- PyCArgObject * res ;
2277
- Py_BEGIN_CRITICAL_SECTION (self );
2278
- res = PyCSimpleType_paramfunc_lock_held (st , self );
2279
- Py_END_CRITICAL_SECTION ();
2280
- return res ;
2281
- }
2282
2269
2283
2270
static int
2284
2271
PyCSimpleType_init (PyObject * self , PyObject * args , PyObject * kwds )
@@ -2766,6 +2753,7 @@ make_funcptrtype_dict(ctypes_state *st, PyObject *attrdict, StgInfo *stginfo)
2766
2753
static PyCArgObject *
2767
2754
PyCFuncPtrType_paramfunc (ctypes_state * st , CDataObject * self )
2768
2755
{
2756
+ _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (self );
2769
2757
PyCArgObject * parg ;
2770
2758
2771
2759
parg = PyCArgObject_new (st );
@@ -2775,7 +2763,7 @@ PyCFuncPtrType_paramfunc(ctypes_state *st, CDataObject *self)
2775
2763
parg -> tag = 'P' ;
2776
2764
parg -> pffi_type = & ffi_type_pointer ;
2777
2765
parg -> obj = Py_NewRef (self );
2778
- parg -> value .p = locked_deref ( self ) ;
2766
+ parg -> value .p = * ( void * * ) self -> b_ptr ;
2779
2767
return parg ;
2780
2768
}
2781
2769
@@ -5827,7 +5815,11 @@ Pointer_subscript(PyObject *myself, PyObject *item)
5827
5815
static int
5828
5816
Pointer_bool (PyObject * self )
5829
5817
{
5830
- return locked_deref (_CDataObject_CAST (self )) != NULL ;
5818
+ int res ;
5819
+ Py_BEGIN_CRITICAL_SECTION (self );
5820
+ res = * (void * * )_CDataObject_CAST (self )-> b_ptr != NULL ;
5821
+ Py_END_CRITICAL_SECTION ();
5822
+ return res ;
5831
5823
}
5832
5824
5833
5825
static PyType_Slot pycpointer_slots [] = {
0 commit comments