@@ -792,13 +792,8 @@ static PyObject *PyTclObject_Type;
792
792
static PyObject *
793
793
newPyTclObject (Tcl_Obj * arg )
794
794
{
795
- PyTypeObject * type ;
796
795
PyTclObject * self ;
797
-
798
- type = (PyTypeObject * )PyTclObject_Type ;
799
- assert (type != NULL );
800
- assert (type -> tp_alloc != NULL );
801
- self = (PyTclObject * )type -> tp_alloc (type , 0 );
796
+ self = PyObject_New (PyTclObject , (PyTypeObject * ) PyTclObject_Type );
802
797
if (self == NULL )
803
798
return NULL ;
804
799
Tcl_IncrRefCount (arg );
@@ -808,24 +803,16 @@ newPyTclObject(Tcl_Obj *arg)
808
803
}
809
804
810
805
static void
811
- PyTclObject_dealloc (PyObject * op )
806
+ PyTclObject_dealloc (PyObject * _self )
812
807
{
813
- PyTypeObject * tp = Py_TYPE (op );
814
- PyObject_GC_UnTrack (op );
815
- PyTclObject * self = PyTclObject_CAST (op );
808
+ PyTclObject * self = PyTclObject_CAST (_self );
809
+ PyObject * tp = (PyObject * ) Py_TYPE (self );
816
810
Tcl_DecrRefCount (self -> value );
817
811
Py_XDECREF (self -> string );
818
- tp -> tp_free (self );
812
+ PyObject_Free (self );
819
813
Py_DECREF (tp );
820
814
}
821
815
822
- static int
823
- PyTclObject_traverse (PyObject * op , visitproc visit , void * arg )
824
- {
825
- Py_VISIT (Py_TYPE (op ));
826
- return 0 ;
827
- }
828
-
829
816
/* Like _str, but create Unicode if necessary. */
830
817
PyDoc_STRVAR (PyTclObject_string__doc__ ,
831
818
"the string representation of this object, either as str or bytes" );
@@ -914,7 +901,6 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
914
901
915
902
static PyType_Slot PyTclObject_Type_slots [] = {
916
903
{Py_tp_dealloc , PyTclObject_dealloc },
917
- {Py_tp_traverse , PyTclObject_traverse },
918
904
{Py_tp_repr , PyTclObject_repr },
919
905
{Py_tp_str , PyTclObject_str },
920
906
{Py_tp_getattro , PyObject_GenericGetAttr },
@@ -929,7 +915,7 @@ static PyType_Spec PyTclObject_Type_spec = {
929
915
.flags = (
930
916
Py_TPFLAGS_DEFAULT
931
917
| Py_TPFLAGS_DISALLOW_INSTANTIATION
932
- | Py_TPFLAGS_HAVE_GC
918
+ | Py_TPFLAGS_IMMUTABLETYPE
933
919
),
934
920
.slots = PyTclObject_Type_slots ,
935
921
};
0 commit comments