@@ -502,7 +502,8 @@ initialize_static_type(PyTypeObject *type, PyStructSequence_Desc *desc,
502502}
503503
504504int
505- _PyStructSequence_InitBuiltinWithFlags (PyTypeObject * type ,
505+ _PyStructSequence_InitBuiltinWithFlags (PyInterpreterState * interp ,
506+ PyTypeObject * type ,
506507 PyStructSequence_Desc * desc ,
507508 unsigned long tp_flags )
508509{
@@ -536,7 +537,7 @@ _PyStructSequence_InitBuiltinWithFlags(PyTypeObject *type,
536537 }
537538#endif
538539
539- if (_PyStaticType_InitBuiltin (type ) < 0 ) {
540+ if (_PyStaticType_InitBuiltin (interp , type ) < 0 ) {
540541 PyErr_Format (PyExc_RuntimeError ,
541542 "Can't initialize builtin type %s" ,
542543 desc -> name );
@@ -606,7 +607,7 @@ PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
606607 initialized via _PyStructSequence_InitBuiltinWithFlags(). */
607608
608609void
609- _PyStructSequence_FiniBuiltin (PyTypeObject * type )
610+ _PyStructSequence_FiniBuiltin (PyInterpreterState * interp , PyTypeObject * type )
610611{
611612 // Ensure that the type is initialized
612613 assert (type -> tp_name != NULL );
@@ -620,13 +621,15 @@ _PyStructSequence_FiniBuiltin(PyTypeObject *type)
620621 return ;
621622 }
622623
623- _PyStaticType_Dealloc (type );
624+ _PyStaticType_Dealloc (interp , type );
624625
625- // Undo _PyStructSequence_InitBuiltinWithFlags().
626- type -> tp_name = NULL ;
627- PyMem_Free (type -> tp_members );
628- type -> tp_members = NULL ;
629- type -> tp_base = NULL ;
626+ if (_Py_IsMainInterpreter (interp )) {
627+ // Undo _PyStructSequence_InitBuiltinWithFlags().
628+ type -> tp_name = NULL ;
629+ PyMem_Free (type -> tp_members );
630+ type -> tp_members = NULL ;
631+ type -> tp_base = NULL ;
632+ }
630633}
631634
632635
0 commit comments