@@ -717,7 +717,7 @@ StructUnionType_init(PyObject *self, PyObject *args, PyObject *kwds, int isStruc
717717 ret = PyCStgInfo_clone (info , baseinfo );
718718 if (ret >= 0 ) {
719719 assert (stginfo_get_dict_final (info ) == 0 );
720- stginfo_set_dict_final (baseinfo );
720+ stginfo_set_dict_final_lock_held (baseinfo );
721721 }
722722 STGINFO_UNLOCK2 ();
723723 return ret ;
@@ -3177,11 +3177,7 @@ PyCData_FromBaseObj(ctypes_state *st,
31773177 return NULL ;
31783178 }
31793179
3180- if (stginfo_get_dict_final (info ) != 1 ) {
3181- STGINFO_LOCK (info );
3182- stginfo_set_dict_final (info );
3183- STGINFO_UNLOCK ();
3184- }
3180+ stginfo_set_dict_final (info );
31853181
31863182 assert (CDataObject_Check (st , cmem ));
31873183 cmem -> b_length = info -> length ;
@@ -3226,11 +3222,8 @@ PyCData_AtAddress(ctypes_state *st, PyObject *type, void *buf)
32263222 "abstract class" );
32273223 return NULL ;
32283224 }
3229- if (stginfo_get_dict_final (info ) != 1 ) {
3230- STGINFO_LOCK (info );
3231- stginfo_set_dict_final (info );
3232- STGINFO_UNLOCK ();
3233- }
3225+
3226+ stginfo_set_dict_final (info );
32343227
32353228 pd = (CDataObject * )((PyTypeObject * )type )-> tp_alloc ((PyTypeObject * )type , 0 );
32363229 if (!pd ) {
@@ -3464,11 +3457,8 @@ generic_pycdata_new(ctypes_state *st,
34643457 "abstract class" );
34653458 return NULL ;
34663459 }
3467- if (stginfo_get_dict_final (info ) != 1 ) {
3468- STGINFO_LOCK (info );
3469- stginfo_set_dict_final (info );
3470- STGINFO_UNLOCK ();
3471- }
3460+
3461+ stginfo_set_dict_final (info );
34723462
34733463 obj = (CDataObject * )type -> tp_alloc (type , 0 );
34743464 if (!obj )
0 commit comments