Skip to content

Commit 6e4c0bc

Browse files
Split up type_ready_set_bases().
1 parent 9d457e1 commit 6e4c0bc

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Objects/typeobject.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6988,12 +6988,8 @@ type_ready_pre_checks(PyTypeObject *type)
69886988

69896989

69906990
static int
6991-
type_ready_set_bases(PyTypeObject *type)
6991+
type_ready_set_base(PyTypeObject *type)
69926992
{
6993-
if (lookup_tp_bases(type) != NULL) {
6994-
return 0;
6995-
}
6996-
69976993
/* Initialize tp_base (defaults to BaseObject unless that's us) */
69986994
PyTypeObject *base = type->tp_base;
69996995
if (base == NULL && type != &PyBaseObject_Type) {
@@ -7017,18 +7013,34 @@ type_ready_set_bases(PyTypeObject *type)
70177013
}
70187014
}
70197015

7016+
return 0;
7017+
}
7018+
7019+
static int
7020+
type_ready_set_type(PyTypeObject *type)
7021+
{
70207022
/* Initialize ob_type if NULL. This means extensions that want to be
70217023
compilable separately on Windows can call PyType_Ready() instead of
70227024
initializing the ob_type field of their type objects. */
70237025
/* The test for base != NULL is really unnecessary, since base is only
70247026
NULL when type is &PyBaseObject_Type, and we know its ob_type is
70257027
not NULL (it's initialized to &PyType_Type). But coverity doesn't
70267028
know that. */
7029+
PyTypeObject *base = type->tp_base;
70277030
if (Py_IS_TYPE(type, NULL) && base != NULL) {
70287031
Py_SET_TYPE(type, Py_TYPE(base));
70297032
}
70307033

7031-
/* Initialize tp_bases */
7034+
return 0;
7035+
}
7036+
7037+
static int
7038+
type_ready_set_bases(PyTypeObject *type)
7039+
{
7040+
if (lookup_tp_bases(type) != NULL) {
7041+
return 0;
7042+
}
7043+
70327044
PyObject *bases = lookup_tp_bases(type);
70337045
if (bases == NULL) {
70347046
PyTypeObject *base = type->tp_base;
@@ -7430,6 +7442,12 @@ type_ready(PyTypeObject *type, int rerunbuiltin)
74307442
if (type_ready_set_dict(type) < 0) {
74317443
goto error;
74327444
}
7445+
if (type_ready_set_base(type) < 0) {
7446+
goto error;
7447+
}
7448+
if (type_ready_set_type(type) < 0) {
7449+
goto error;
7450+
}
74337451
if (type_ready_set_bases(type) < 0) {
74347452
goto error;
74357453
}

0 commit comments

Comments
 (0)