@@ -56,15 +56,15 @@ generic_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5656 assert (type -> tp_base -> tp_new != NULL );
5757 inst = type -> tp_base -> tp_new (type -> tp_base , args , kwds );
5858 if (inst != NULL )
59- inst -> ob_type = type ;
59+ Py_TYPE ( inst ) = type ;
6060 return inst ;
6161}
6262
6363int
6464generic_init (PyObject * ob , PyObject * args , PyObject * kwds )
6565{
6666
67- initproc init = ob -> ob_type -> tp_base -> tp_init ;
67+ initproc init = Py_TYPE ( ob ) -> tp_base -> tp_init ;
6868
6969 if (init )
7070 return init (ob , args , kwds );
@@ -74,8 +74,8 @@ generic_init(PyObject *ob, PyObject *args, PyObject *kwds)
7474static PyObject *
7575generic_setstate (PyObject * self , PyObject * args )
7676{
77- if (is_wrong_type (self -> ob_type )) return NULL ;
78- self -> ob_type = self -> ob_type -> tp_base ;
77+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
78+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
7979 Py_INCREF (self );
8080 return self ;
8181}
@@ -112,29 +112,29 @@ _new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
112112static void
113113_wrap_dealloc (PyObject * ob )
114114{
115- ob -> ob_type = ob -> ob_type -> tp_base ;
116- if (ob -> ob_type -> tp_dealloc != NULL )
117- ob -> ob_type -> tp_dealloc (ob );
115+ Py_TYPE ( ob ) = Py_TYPE ( ob ) -> tp_base ;
116+ if (Py_TYPE ( ob ) -> tp_dealloc != NULL )
117+ Py_TYPE ( ob ) -> tp_dealloc (ob );
118118}
119119
120120static int
121121_wrap_traverse (PyObject * ob , visitproc visit , void * arg )
122122{
123- PyTypeObject * type = ob -> ob_type ;
123+ PyTypeObject * type = Py_TYPE ( ob ) ;
124124 int ret = 0 ;
125- ob -> ob_type = ob -> ob_type -> tp_base ;
126- if (ob -> ob_type -> tp_traverse != NULL )
127- ret = ob -> ob_type -> tp_traverse (ob , visit , arg );
128- ob -> ob_type = type ;
125+ Py_TYPE ( ob ) = type -> tp_base ;
126+ if (Py_TYPE ( ob ) -> tp_traverse != NULL )
127+ ret = Py_TYPE ( ob ) -> tp_traverse (ob , visit , arg );
128+ Py_TYPE ( ob ) = type ;
129129 return ret ;
130130}
131131
132132static void
133133_wrap_clear (PyObject * ob )
134134{
135- ob -> ob_type = ob -> ob_type -> tp_base ;
136- if (ob -> ob_type -> tp_clear != NULL )
137- ob -> ob_type -> tp_clear (ob );
135+ Py_TYPE ( ob ) = Py_TYPE ( ob ) -> tp_base ;
136+ if (Py_TYPE ( ob ) -> tp_clear != NULL )
137+ Py_TYPE ( ob ) -> tp_clear (ob );
138138}
139139
140140
@@ -699,7 +699,7 @@ cell_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
699699 return NULL ;
700700 ob = PyCell_New (NULL );
701701 if (ob != NULL )
702- ob -> ob_type = type ;
702+ Py_TYPE ( ob ) = type ;
703703 return ob ;
704704}
705705
@@ -711,14 +711,14 @@ cell_setstate(PyObject *self, PyObject *args)
711711 PyCellObject * cell = (PyCellObject * ) self ;
712712 PyObject * ob = NULL ;
713713
714- if (is_wrong_type (self -> ob_type )) return NULL ;
714+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
715715 if (!PyArg_ParseTuple (args , "|O" , & ob ))
716716 return NULL ;
717717 Py_XINCREF (ob );
718718 Py_CLEAR (cell -> ob_ref );
719719 cell -> ob_ref = ob ;
720720 Py_INCREF (self );
721- self -> ob_type = self -> ob_type -> tp_base ;
721+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
722722 return self ;
723723}
724724
@@ -770,7 +770,7 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kewd)
770770 if ((co = Py_CompileString ("" , "" , Py_file_input )) != NULL )
771771 if ((globals = PyDict_New ()) != NULL )
772772 if ((ob = PyFunction_New (co , globals )) != NULL )
773- ob -> ob_type = type ;
773+ Py_TYPE ( ob ) = type ;
774774 Py_XDECREF (co );
775775 Py_XDECREF (globals );
776776 return ob ;
@@ -785,13 +785,13 @@ func_setstate(PyObject *self, PyObject *args)
785785 PyFunctionObject * fu ;
786786 PyObject * args2 ;
787787
788- if (is_wrong_type (self -> ob_type )) return NULL ;
789- self -> ob_type = self -> ob_type -> tp_base ;
788+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
789+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
790790 args2 = PyTuple_GetSlice (args , 0 , 5 );
791791 if (args2 == NULL )
792792 return NULL ;
793793 fu = (PyFunctionObject * )
794- self -> ob_type -> tp_new (self -> ob_type , args2 , NULL );
794+ Py_TYPE ( self ) -> tp_new (Py_TYPE ( self ) , args2 , NULL );
795795 Py_DECREF (args2 );
796796 if (fu != NULL ) {
797797 PyFunctionObject * target = (PyFunctionObject * ) self ;
@@ -1650,7 +1650,7 @@ methw_setstate(PyObject *self, PyObject *args)
16501650 PyObject * name , * inst ;
16511651 PyObject * w ;
16521652
1653- if (is_wrong_type (self -> ob_type )) return NULL ;
1653+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
16541654 if (!PyArg_ParseTuple (args , "O!O:method-wrapper" ,
16551655 & PyUnicode_Type , & name ,
16561656 & inst ))
@@ -1675,7 +1675,7 @@ methw_setstate(PyObject *self, PyObject *args)
16751675 neww -> self = oldw -> self ;
16761676 }
16771677 Py_DECREF (w );
1678- self -> ob_type = self -> ob_type -> tp_base ;
1678+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
16791679 Py_INCREF (self );
16801680 return self ;
16811681}
0 commit comments