@@ -43,15 +43,15 @@ generic_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
4343 assert (type -> tp_base -> tp_new != NULL );
4444 inst = type -> tp_base -> tp_new (type -> tp_base , args , kwds );
4545 if (inst != NULL )
46- inst -> ob_type = type ;
46+ Py_TYPE ( inst ) = type ;
4747 return inst ;
4848}
4949
5050int
5151generic_init (PyObject * ob , PyObject * args , PyObject * kwds )
5252{
5353
54- initproc init = ob -> ob_type -> tp_base -> tp_init ;
54+ initproc init = Py_TYPE ( ob ) -> tp_base -> tp_init ;
5555
5656 if (init )
5757 return init (ob , args , kwds );
@@ -61,8 +61,8 @@ generic_init(PyObject *ob, PyObject *args, PyObject *kwds)
6161static PyObject *
6262generic_setstate (PyObject * self , PyObject * args )
6363{
64- if (is_wrong_type (self -> ob_type )) return NULL ;
65- self -> ob_type = self -> ob_type -> tp_base ;
64+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
65+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
6666 Py_INCREF (self );
6767 return self ;
6868}
@@ -99,29 +99,29 @@ _new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
9999static void
100100_wrap_dealloc (PyObject * ob )
101101{
102- ob -> ob_type = ob -> ob_type -> tp_base ;
103- if (ob -> ob_type -> tp_dealloc != NULL )
104- ob -> ob_type -> tp_dealloc (ob );
102+ Py_TYPE ( ob ) = Py_TYPE ( ob ) -> tp_base ;
103+ if (Py_TYPE ( ob ) -> tp_dealloc != NULL )
104+ Py_TYPE ( ob ) -> tp_dealloc (ob );
105105}
106106
107107static int
108108_wrap_traverse (PyObject * ob , visitproc visit , void * arg )
109109{
110- PyTypeObject * type = ob -> ob_type ;
110+ PyTypeObject * type = Py_TYPE ( ob ) ;
111111 int ret = 0 ;
112- ob -> ob_type = ob -> ob_type -> tp_base ;
113- if (ob -> ob_type -> tp_traverse != NULL )
114- ret = ob -> ob_type -> tp_traverse (ob , visit , arg );
115- ob -> ob_type = type ;
112+ Py_TYPE ( ob ) = type -> tp_base ;
113+ if (Py_TYPE ( ob ) -> tp_traverse != NULL )
114+ ret = Py_TYPE ( ob ) -> tp_traverse (ob , visit , arg );
115+ Py_TYPE ( ob ) = type ;
116116 return ret ;
117117}
118118
119119static void
120120_wrap_clear (PyObject * ob )
121121{
122- ob -> ob_type = ob -> ob_type -> tp_base ;
123- if (ob -> ob_type -> tp_clear != NULL )
124- ob -> ob_type -> tp_clear (ob );
122+ Py_TYPE ( ob ) = Py_TYPE ( ob ) -> tp_base ;
123+ if (Py_TYPE ( ob ) -> tp_clear != NULL )
124+ Py_TYPE ( ob ) -> tp_clear (ob );
125125}
126126
127127
@@ -604,7 +604,7 @@ cell_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
604604 return NULL ;
605605 ob = PyCell_New (NULL );
606606 if (ob != NULL )
607- ob -> ob_type = type ;
607+ Py_TYPE ( ob ) = type ;
608608 return ob ;
609609}
610610
@@ -616,14 +616,14 @@ cell_setstate(PyObject *self, PyObject *args)
616616 PyCellObject * cell = (PyCellObject * ) self ;
617617 PyObject * ob = NULL ;
618618
619- if (is_wrong_type (self -> ob_type )) return NULL ;
619+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
620620 if (!PyArg_ParseTuple (args , "|O" , & ob ))
621621 return NULL ;
622622 Py_XDECREF (cell -> ob_ref );
623623 cell -> ob_ref = ob ;
624624 Py_XINCREF (cell -> ob_ref );
625625 Py_INCREF (self );
626- self -> ob_type = self -> ob_type -> tp_base ;
626+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
627627 return self ;
628628}
629629
@@ -675,7 +675,7 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kewd)
675675 if ((co = Py_CompileString ("" , "" , Py_file_input )) != NULL )
676676 if ((globals = PyDict_New ()) != NULL )
677677 if ((ob = PyFunction_New (co , globals )) != NULL )
678- ob -> ob_type = type ;
678+ Py_TYPE ( ob ) = type ;
679679 Py_XDECREF (co );
680680 Py_XDECREF (globals );
681681 return ob ;
@@ -690,13 +690,13 @@ func_setstate(PyObject *self, PyObject *args)
690690 PyFunctionObject * fu ;
691691 PyObject * args2 ;
692692
693- if (is_wrong_type (self -> ob_type )) return NULL ;
694- self -> ob_type = self -> ob_type -> tp_base ;
693+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
694+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
695695 args2 = PyTuple_GetSlice (args , 0 , 5 );
696696 if (args2 == NULL )
697697 return NULL ;
698698 fu = (PyFunctionObject * )
699- self -> ob_type -> tp_new (self -> ob_type , args2 , NULL );
699+ Py_TYPE ( self ) -> tp_new (Py_TYPE ( self ) , args2 , NULL );
700700 Py_DECREF (args2 );
701701 if (fu != NULL ) {
702702 PyFunctionObject * target = (PyFunctionObject * ) self ;
@@ -2072,7 +2072,7 @@ methw_setstate(PyObject *self, PyObject *args)
20722072 PyObject * name , * inst ;
20732073 PyObject * w ;
20742074
2075- if (is_wrong_type (self -> ob_type )) return NULL ;
2075+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
20762076 if (!PyArg_ParseTuple (args , "O!O:method-wrapper" ,
20772077 & PyString_Type , & name ,
20782078 & inst ))
@@ -2097,7 +2097,7 @@ methw_setstate(PyObject *self, PyObject *args)
20972097 neww -> self = oldw -> self ;
20982098 }
20992099 Py_DECREF (w );
2100- self -> ob_type = self -> ob_type -> tp_base ;
2100+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
21012101 Py_INCREF (self );
21022102 return self ;
21032103}
0 commit comments