Skip to content

Commit fe12a90

Browse files
Split up type_ready_set_bases().
1 parent 7be667d commit fe12a90

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
@@ -6996,12 +6996,8 @@ type_ready_pre_checks(PyTypeObject *type)
69966996

69976997

69986998
static int
6999-
type_ready_set_bases(PyTypeObject *type)
6999+
type_ready_set_base(PyTypeObject *type)
70007000
{
7001-
if (lookup_tp_bases(type) != NULL) {
7002-
return 0;
7003-
}
7004-
70057001
/* Initialize tp_base (defaults to BaseObject unless that's us) */
70067002
PyTypeObject *base = type->tp_base;
70077003
if (base == NULL && type != &PyBaseObject_Type) {
@@ -7025,18 +7021,34 @@ type_ready_set_bases(PyTypeObject *type)
70257021
}
70267022
}
70277023

7024+
return 0;
7025+
}
7026+
7027+
static int
7028+
type_ready_set_type(PyTypeObject *type)
7029+
{
70287030
/* Initialize ob_type if NULL. This means extensions that want to be
70297031
compilable separately on Windows can call PyType_Ready() instead of
70307032
initializing the ob_type field of their type objects. */
70317033
/* The test for base != NULL is really unnecessary, since base is only
70327034
NULL when type is &PyBaseObject_Type, and we know its ob_type is
70337035
not NULL (it's initialized to &PyType_Type). But coverity doesn't
70347036
know that. */
7037+
PyTypeObject *base = type->tp_base;
70357038
if (Py_IS_TYPE(type, NULL) && base != NULL) {
70367039
Py_SET_TYPE(type, Py_TYPE(base));
70377040
}
70387041

7039-
/* Initialize tp_bases */
7042+
return 0;
7043+
}
7044+
7045+
static int
7046+
type_ready_set_bases(PyTypeObject *type)
7047+
{
7048+
if (lookup_tp_bases(type) != NULL) {
7049+
return 0;
7050+
}
7051+
70407052
PyObject *bases = lookup_tp_bases(type);
70417053
if (bases == NULL) {
70427054
PyTypeObject *base = type->tp_base;
@@ -7446,6 +7458,12 @@ type_ready(PyTypeObject *type, int rerunbuiltin)
74467458
if (type_ready_set_dict(type) < 0) {
74477459
goto error;
74487460
}
7461+
if (type_ready_set_base(type) < 0) {
7462+
goto error;
7463+
}
7464+
if (type_ready_set_type(type) < 0) {
7465+
goto error;
7466+
}
74497467
if (type_ready_set_bases(type) < 0) {
74507468
goto error;
74517469
}

0 commit comments

Comments
 (0)