@@ -6996,12 +6996,8 @@ type_ready_pre_checks(PyTypeObject *type)
6996
6996
6997
6997
6998
6998
static int
6999
- type_ready_set_bases (PyTypeObject * type )
6999
+ type_ready_set_base (PyTypeObject * type )
7000
7000
{
7001
- if (lookup_tp_bases (type ) != NULL ) {
7002
- return 0 ;
7003
- }
7004
-
7005
7001
/* Initialize tp_base (defaults to BaseObject unless that's us) */
7006
7002
PyTypeObject * base = type -> tp_base ;
7007
7003
if (base == NULL && type != & PyBaseObject_Type ) {
@@ -7025,18 +7021,34 @@ type_ready_set_bases(PyTypeObject *type)
7025
7021
}
7026
7022
}
7027
7023
7024
+ return 0 ;
7025
+ }
7026
+
7027
+ static int
7028
+ type_ready_set_type (PyTypeObject * type )
7029
+ {
7028
7030
/* Initialize ob_type if NULL. This means extensions that want to be
7029
7031
compilable separately on Windows can call PyType_Ready() instead of
7030
7032
initializing the ob_type field of their type objects. */
7031
7033
/* The test for base != NULL is really unnecessary, since base is only
7032
7034
NULL when type is &PyBaseObject_Type, and we know its ob_type is
7033
7035
not NULL (it's initialized to &PyType_Type). But coverity doesn't
7034
7036
know that. */
7037
+ PyTypeObject * base = type -> tp_base ;
7035
7038
if (Py_IS_TYPE (type , NULL ) && base != NULL ) {
7036
7039
Py_SET_TYPE (type , Py_TYPE (base ));
7037
7040
}
7038
7041
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
+
7040
7052
PyObject * bases = lookup_tp_bases (type );
7041
7053
if (bases == NULL ) {
7042
7054
PyTypeObject * base = type -> tp_base ;
@@ -7446,6 +7458,12 @@ type_ready(PyTypeObject *type, int rerunbuiltin)
7446
7458
if (type_ready_set_dict (type ) < 0 ) {
7447
7459
goto error ;
7448
7460
}
7461
+ if (type_ready_set_base (type ) < 0 ) {
7462
+ goto error ;
7463
+ }
7464
+ if (type_ready_set_type (type ) < 0 ) {
7465
+ goto error ;
7466
+ }
7449
7467
if (type_ready_set_bases (type ) < 0 ) {
7450
7468
goto error ;
7451
7469
}
0 commit comments