@@ -56,15 +56,15 @@ generic_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
56
56
assert (type -> tp_base -> tp_new != NULL );
57
57
inst = type -> tp_base -> tp_new (type -> tp_base , args , kwds );
58
58
if (inst != NULL )
59
- inst -> ob_type = type ;
59
+ Py_TYPE ( inst ) = type ;
60
60
return inst ;
61
61
}
62
62
63
63
int
64
64
generic_init (PyObject * ob , PyObject * args , PyObject * kwds )
65
65
{
66
66
67
- initproc init = ob -> ob_type -> tp_base -> tp_init ;
67
+ initproc init = Py_TYPE ( ob ) -> tp_base -> tp_init ;
68
68
69
69
if (init )
70
70
return init (ob , args , kwds );
@@ -74,8 +74,8 @@ generic_init(PyObject *ob, PyObject *args, PyObject *kwds)
74
74
static PyObject *
75
75
generic_setstate (PyObject * self , PyObject * args )
76
76
{
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 ;
79
79
Py_INCREF (self );
80
80
return self ;
81
81
}
@@ -112,29 +112,29 @@ _new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
112
112
static void
113
113
_wrap_dealloc (PyObject * ob )
114
114
{
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 );
118
118
}
119
119
120
120
static int
121
121
_wrap_traverse (PyObject * ob , visitproc visit , void * arg )
122
122
{
123
- PyTypeObject * type = ob -> ob_type ;
123
+ PyTypeObject * type = Py_TYPE ( ob ) ;
124
124
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 ;
129
129
return ret ;
130
130
}
131
131
132
132
static void
133
133
_wrap_clear (PyObject * ob )
134
134
{
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 );
138
138
}
139
139
140
140
@@ -699,7 +699,7 @@ cell_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
699
699
return NULL ;
700
700
ob = PyCell_New (NULL );
701
701
if (ob != NULL )
702
- ob -> ob_type = type ;
702
+ Py_TYPE ( ob ) = type ;
703
703
return ob ;
704
704
}
705
705
@@ -711,14 +711,14 @@ cell_setstate(PyObject *self, PyObject *args)
711
711
PyCellObject * cell = (PyCellObject * ) self ;
712
712
PyObject * ob = NULL ;
713
713
714
- if (is_wrong_type (self -> ob_type )) return NULL ;
714
+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
715
715
if (!PyArg_ParseTuple (args , "|O" , & ob ))
716
716
return NULL ;
717
717
Py_XINCREF (ob );
718
718
Py_CLEAR (cell -> ob_ref );
719
719
cell -> ob_ref = ob ;
720
720
Py_INCREF (self );
721
- self -> ob_type = self -> ob_type -> tp_base ;
721
+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
722
722
return self ;
723
723
}
724
724
@@ -770,7 +770,7 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kewd)
770
770
if ((co = Py_CompileString ("" , "" , Py_file_input )) != NULL )
771
771
if ((globals = PyDict_New ()) != NULL )
772
772
if ((ob = PyFunction_New (co , globals )) != NULL )
773
- ob -> ob_type = type ;
773
+ Py_TYPE ( ob ) = type ;
774
774
Py_XDECREF (co );
775
775
Py_XDECREF (globals );
776
776
return ob ;
@@ -785,13 +785,13 @@ func_setstate(PyObject *self, PyObject *args)
785
785
PyFunctionObject * fu ;
786
786
PyObject * args2 ;
787
787
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 ;
790
790
args2 = PyTuple_GetSlice (args , 0 , 5 );
791
791
if (args2 == NULL )
792
792
return NULL ;
793
793
fu = (PyFunctionObject * )
794
- self -> ob_type -> tp_new (self -> ob_type , args2 , NULL );
794
+ Py_TYPE ( self ) -> tp_new (Py_TYPE ( self ) , args2 , NULL );
795
795
Py_DECREF (args2 );
796
796
if (fu != NULL ) {
797
797
PyFunctionObject * target = (PyFunctionObject * ) self ;
@@ -1650,7 +1650,7 @@ methw_setstate(PyObject *self, PyObject *args)
1650
1650
PyObject * name , * inst ;
1651
1651
PyObject * w ;
1652
1652
1653
- if (is_wrong_type (self -> ob_type )) return NULL ;
1653
+ if (is_wrong_type (Py_TYPE ( self ) )) return NULL ;
1654
1654
if (!PyArg_ParseTuple (args , "O!O:method-wrapper" ,
1655
1655
& PyUnicode_Type , & name ,
1656
1656
& inst ))
@@ -1675,7 +1675,7 @@ methw_setstate(PyObject *self, PyObject *args)
1675
1675
neww -> self = oldw -> self ;
1676
1676
}
1677
1677
Py_DECREF (w );
1678
- self -> ob_type = self -> ob_type -> tp_base ;
1678
+ Py_TYPE ( self ) = Py_TYPE ( self ) -> tp_base ;
1679
1679
Py_INCREF (self );
1680
1680
return self ;
1681
1681
}
0 commit comments