Commit 8d96ce22 authored by Georg Brandl's avatar Georg Brandl

#4576: fix ob_type access.

parent 5a98b792
...@@ -265,7 +265,7 @@ allocation and deallocation. At a minimum, we need a deallocation method:: ...@@ -265,7 +265,7 @@ allocation and deallocation. At a minimum, we need a deallocation method::
{ {
Py_XDECREF(self->first); Py_XDECREF(self->first);
Py_XDECREF(self->last); Py_XDECREF(self->last);
self->ob_type->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
} }
which is assigned to the :attr:`tp_dealloc` member:: which is assigned to the :attr:`tp_dealloc` member::
...@@ -759,7 +759,7 @@ to use it:: ...@@ -759,7 +759,7 @@ to use it::
Noddy_dealloc(Noddy* self) Noddy_dealloc(Noddy* self)
{ {
Noddy_clear(self); Noddy_clear(self);
self->ob_type->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
} }
Notice the use of a temporary variable in :cfunc:`Noddy_clear`. We use the Notice the use of a temporary variable in :cfunc:`Noddy_clear`. We use the
...@@ -952,7 +952,7 @@ needs to be freed here as well. Here is an example of this function:: ...@@ -952,7 +952,7 @@ needs to be freed here as well. Here is an example of this function::
newdatatype_dealloc(newdatatypeobject * obj) newdatatype_dealloc(newdatatypeobject * obj)
{ {
free(obj->obj_UnderlyingDatatypePtr); free(obj->obj_UnderlyingDatatypePtr);
obj->ob_type->tp_free(obj); Py_TYPE(obj)->tp_free(obj);
} }
.. index:: .. index::
...@@ -995,7 +995,7 @@ done. This can be done using the :cfunc:`PyErr_Fetch` and ...@@ -995,7 +995,7 @@ done. This can be done using the :cfunc:`PyErr_Fetch` and
Py_DECREF(self->my_callback); Py_DECREF(self->my_callback);
} }
obj->ob_type->tp_free((PyObject*)self); Py_TYPE(obj)->tp_free((PyObject*)self);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment