diff --git a/Objects/structseq.c b/Objects/structseq.c index f6d7019789b1ff7..d772b16e815cc73 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -510,16 +510,21 @@ _PyStructSequence_InitBuiltinWithFlags(PyTypeObject *type, PyStructSequence_Desc *desc, unsigned long tp_flags) { + PyMemberDef *members; + Py_ssize_t n_members, n_unnamed_members; + if (type->tp_flags & Py_TPFLAGS_READY) { if (_PyStaticType_InitBuiltin(type) < 0) { goto failed_init_builtin; } + n_members = count_members(desc, &n_unnamed_members); + if (initialize_structseq_dict( + desc, _PyType_GetDict(type), n_members, n_unnamed_members) < 0) { + return -1; + } return 0; } - PyMemberDef *members; - Py_ssize_t n_members, n_unnamed_members; - members = initialize_members(desc, &n_members, &n_unnamed_members); if (members == NULL) { return -1;