@@ -252,7 +252,7 @@ managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self,
252
252
state -> type = NULL ;
253
253
assert (state -> tp_weaklist == NULL ); // It was already cleared out.
254
254
255
- if (final ) {
255
+ if (final && isbuiltin ) {
256
256
managed_static_type_index_clear (self );
257
257
}
258
258
@@ -400,7 +400,9 @@ set_tp_bases(PyTypeObject *self, PyObject *bases)
400
400
if (self -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
401
401
// XXX tp_bases can probably be statically allocated for each
402
402
// static builtin type.
403
- assert (_Py_IsMainInterpreter (_PyInterpreterState_GET ()));
403
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
404
+ managed_static_type_state * state = managed_static_type_state_get (interp , self );
405
+ assert (!state -> isbuiltin || _Py_IsMainInterpreter (interp ));
404
406
assert (self -> tp_bases == NULL );
405
407
if (PyTuple_GET_SIZE (bases ) == 0 ) {
406
408
assert (self -> tp_base == NULL );
@@ -473,7 +475,9 @@ set_tp_mro(PyTypeObject *self, PyObject *mro)
473
475
if (self -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
474
476
// XXX tp_mro can probably be statically allocated for each
475
477
// static builtin type.
476
- assert (_Py_IsMainInterpreter (_PyInterpreterState_GET ()));
478
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
479
+ managed_static_type_state * state = managed_static_type_state_get (interp , self );
480
+ assert (!state -> isbuiltin || _Py_IsMainInterpreter (interp ));
477
481
assert (self -> tp_mro == NULL );
478
482
/* Other checks are done via set_tp_bases. */
479
483
_Py_SetImmortal (mro );
@@ -7832,7 +7836,9 @@ static int
7832
7836
type_ready_set_bases (PyTypeObject * type )
7833
7837
{
7834
7838
if (type -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
7835
- if (!_Py_IsMainInterpreter (_PyInterpreterState_GET ())) {
7839
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
7840
+ managed_static_type_state * state = managed_static_type_state_get (interp , type );
7841
+ if (state -> isbuiltin && !_Py_IsMainInterpreter (interp )) {
7836
7842
assert (lookup_tp_bases (type ) != NULL );
7837
7843
return 0 ;
7838
7844
}
@@ -7966,7 +7972,9 @@ type_ready_mro(PyTypeObject *type)
7966
7972
ASSERT_TYPE_LOCK_HELD ();
7967
7973
7968
7974
if (type -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
7969
- if (!_Py_IsMainInterpreter (_PyInterpreterState_GET ())) {
7975
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
7976
+ managed_static_type_state * state = managed_static_type_state_get (interp , type );
7977
+ if (state -> isbuiltin && !_Py_IsMainInterpreter (interp )) {
7970
7978
assert (lookup_tp_mro (type ) != NULL );
7971
7979
return 0 ;
7972
7980
}
0 commit comments