@@ -6988,12 +6988,8 @@ type_ready_pre_checks(PyTypeObject *type)
6988
6988
6989
6989
6990
6990
static int
6991
- type_ready_set_bases (PyTypeObject * type )
6991
+ type_ready_set_base (PyTypeObject * type )
6992
6992
{
6993
- if (lookup_tp_bases (type ) != NULL ) {
6994
- return 0 ;
6995
- }
6996
-
6997
6993
/* Initialize tp_base (defaults to BaseObject unless that's us) */
6998
6994
PyTypeObject * base = type -> tp_base ;
6999
6995
if (base == NULL && type != & PyBaseObject_Type ) {
@@ -7017,18 +7013,34 @@ type_ready_set_bases(PyTypeObject *type)
7017
7013
}
7018
7014
}
7019
7015
7016
+ return 0 ;
7017
+ }
7018
+
7019
+ static int
7020
+ type_ready_set_type (PyTypeObject * type )
7021
+ {
7020
7022
/* Initialize ob_type if NULL. This means extensions that want to be
7021
7023
compilable separately on Windows can call PyType_Ready() instead of
7022
7024
initializing the ob_type field of their type objects. */
7023
7025
/* The test for base != NULL is really unnecessary, since base is only
7024
7026
NULL when type is &PyBaseObject_Type, and we know its ob_type is
7025
7027
not NULL (it's initialized to &PyType_Type). But coverity doesn't
7026
7028
know that. */
7029
+ PyTypeObject * base = type -> tp_base ;
7027
7030
if (Py_IS_TYPE (type , NULL ) && base != NULL ) {
7028
7031
Py_SET_TYPE (type , Py_TYPE (base ));
7029
7032
}
7030
7033
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
+
7032
7044
PyObject * bases = lookup_tp_bases (type );
7033
7045
if (bases == NULL ) {
7034
7046
PyTypeObject * base = type -> tp_base ;
@@ -7430,6 +7442,12 @@ type_ready(PyTypeObject *type, int rerunbuiltin)
7430
7442
if (type_ready_set_dict (type ) < 0 ) {
7431
7443
goto error ;
7432
7444
}
7445
+ if (type_ready_set_base (type ) < 0 ) {
7446
+ goto error ;
7447
+ }
7448
+ if (type_ready_set_type (type ) < 0 ) {
7449
+ goto error ;
7450
+ }
7433
7451
if (type_ready_set_bases (type ) < 0 ) {
7434
7452
goto error ;
7435
7453
}
0 commit comments