Skip to content

Commit c597d1b

Browse files
committed
Unlink the structseq type from the global list of
objects before initializing it. It might be linked already if there was a Py_Initialize/Py_Finalize cycle earlier; not unlinking it would break the global list.
1 parent 4b501e6 commit c597d1b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Objects/structseq.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
349349
PyMemberDef* members;
350350
int n_members, n_unnamed_members, i, k;
351351

352+
#ifdef Py_TRACE_REFS
353+
/* if the type object was chained, unchain it first
354+
before overwriting its storage */
355+
if (type->_ob_next) {
356+
_Py_ForgetReference((PyObject*)type);
357+
}
358+
#endif
359+
352360
n_unnamed_members = 0;
353361
for (i = 0; desc->fields[i].name != NULL; ++i)
354362
if (desc->fields[i].name == PyStructSequence_UnnamedField)

0 commit comments

Comments
 (0)