@@ -211,6 +211,7 @@ static inline PyObject * lookup_tp_dict(PyTypeObject *type);
211
211
static inline void init_tp_dict (PyTypeObject * type , PyObject * dict );
212
212
static inline void clear_tp_dict (PyTypeObject * type );
213
213
static inline PyObject * lookup_tp_bases (PyTypeObject * type );
214
+ static inline void clear_tp_bases (PyTypeObject * type );
214
215
215
216
int
216
217
_PyType_CheckConsistency (PyTypeObject * type )
@@ -862,6 +863,18 @@ init_tp_bases(PyTypeObject *type, PyObject *bases)
862
863
type -> tp_bases = bases ;
863
864
}
864
865
866
+ static inline void
867
+ clear_tp_bases (PyTypeObject * type )
868
+ {
869
+ if (type -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
870
+ static_builtin_state * state = _PyStaticType_GetState (type );
871
+ assert (state != NULL );
872
+ Py_CLEAR (state -> tp_bases );
873
+ return ;
874
+ }
875
+ Py_CLEAR (type -> tp_bases );
876
+ }
877
+
865
878
static PyObject *
866
879
type_get_bases (PyTypeObject * type , void * context )
867
880
{
@@ -4586,34 +4599,18 @@ clear_static_tp_subclasses(PyTypeObject *type)
4586
4599
clear_tp_subclasses (type );
4587
4600
}
4588
4601
4589
- static void
4590
- clear_static_type_interp_data (PyTypeObject * type )
4591
- {
4592
- if (type -> tp_flags & _Py_TPFLAGS_STATIC_BUILTIN ) {
4593
- static_builtin_state * state = _PyStaticType_GetState (type );
4594
- assert (state != NULL );
4595
-
4596
- Py_CLEAR (state -> tp_dict );
4597
- Py_CLEAR (state -> tp_bases );
4598
- Py_CLEAR (state -> tp_mro );
4599
- }
4600
- else {
4601
- Py_CLEAR (type -> tp_dict );
4602
- Py_CLEAR (type -> tp_bases );
4603
- Py_CLEAR (type -> tp_mro );
4604
- }
4605
- clear_static_tp_subclasses (type );
4606
- }
4607
-
4608
4602
void
4609
4603
_PyStaticType_Dealloc (PyTypeObject * type )
4610
4604
{
4611
4605
assert (!(type -> tp_flags & Py_TPFLAGS_HEAPTYPE ));
4612
4606
4613
4607
type_dealloc_common (type );
4614
4608
4609
+ clear_tp_dict (type );
4610
+ clear_tp_bases (type );
4611
+ clear_tp_mro (type );
4615
4612
Py_CLEAR (type -> tp_cache );
4616
- clear_static_type_interp_data (type );
4613
+ clear_static_tp_subclasses (type );
4617
4614
4618
4615
// PyObject_ClearWeakRefs() raises an exception if Py_REFCNT() != 0
4619
4616
if (Py_REFCNT (type ) == 0 ) {
@@ -4647,9 +4644,9 @@ type_dealloc(PyTypeObject *type)
4647
4644
PyObject_ClearWeakRefs ((PyObject * )type );
4648
4645
4649
4646
Py_XDECREF (type -> tp_base );
4650
- Py_XDECREF (type -> tp_dict );
4651
- Py_XDECREF (type -> tp_bases );
4652
- Py_XDECREF (type -> tp_mro );
4647
+ clear_tp_dict (type );
4648
+ clear_tp_bases (type );
4649
+ clear_tp_mro (type );
4653
4650
Py_XDECREF (type -> tp_cache );
4654
4651
clear_tp_subclasses (type );
4655
4652
0 commit comments