From 48354b91805ac320609d5e59f8fa82f5b379599f Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Thu, 27 Apr 2023 11:04:29 -0600 Subject: [PATCH] Fix _PyStaticType_InitBuiltin() for subinterpreters. --- Objects/typeobject.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0c7bea09a4e6ff0..a4258f300f5f6be 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6644,6 +6644,10 @@ type_ready_pre_checks(PyTypeObject *type) static int type_ready_set_bases(PyTypeObject *type) { + if (lookup_tp_bases(type) != NULL) { + return 0; + } + /* Initialize tp_base (defaults to BaseObject unless that's us) */ PyTypeObject *base = type->tp_base; if (base == NULL && type != &PyBaseObject_Type) { @@ -7183,6 +7187,11 @@ _PyStaticType_InitBuiltin(PyTypeObject *self) if (self->tp_flags & Py_TPFLAGS_READY) { assert(self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN); assert(_PyType_CheckConsistency(self)); + /* We must explicitly set these for subinterpreters. + tp_subclasses is set lazily. */ + type_ready_set_dict(self); + type_ready_set_bases(self); + type_ready_mro(self); return 0; }