Skip to content

Commit fd5ad20

Browse files
fix clearing of final bit
1 parent e3bec70 commit fd5ad20

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ StructUnionType_init(PyObject *self, PyObject *args, PyObject *kwds, int isStruc
716716
/* copy base info */
717717
ret = PyCStgInfo_clone(info, baseinfo);
718718
if (ret >= 0) {
719-
assert(stginfo_get_dict_final(info) == 0);
719+
stginfo_clear_dict_final_lock_held(info);
720720
stginfo_set_dict_final_lock_held(baseinfo);
721721
}
722722
STGINFO_UNLOCK2();

Modules/_ctypes/ctypes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,13 @@ stginfo_set_dict_final(StgInfo *info)
436436
STGINFO_UNLOCK();
437437
}
438438

439+
static inline void
440+
stginfo_clear_dict_final_lock_held(StgInfo *info)
441+
{
442+
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&info->mutex);
443+
FT_ATOMIC_STORE_INT(info->dict_final, 0);
444+
}
445+
439446
extern int PyCStgInfo_clone(StgInfo *dst_info, StgInfo *src_info);
440447
extern void ctype_clear_stginfo(StgInfo *info);
441448

0 commit comments

Comments
 (0)