Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ed237b

Browse files
committed
#4576: fix ob_type access.
1 parent 8f1a77d commit 2ed237b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Doc/extending/newtypes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ allocation and deallocation. At a minimum, we need a deallocation method::
265265
{
266266
Py_XDECREF(self->first);
267267
Py_XDECREF(self->last);
268-
self->ob_type->tp_free((PyObject*)self);
268+
Py_TYPE(self)->tp_free((PyObject*)self);
269269
}
270270

271271
which is assigned to the :attr:`tp_dealloc` member::
@@ -759,7 +759,7 @@ to use it::
759759
Noddy_dealloc(Noddy* self)
760760
{
761761
Noddy_clear(self);
762-
self->ob_type->tp_free((PyObject*)self);
762+
Py_TYPE(self)->tp_free((PyObject*)self);
763763
}
764764

765765
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::
952952
newdatatype_dealloc(newdatatypeobject * obj)
953953
{
954954
free(obj->obj_UnderlyingDatatypePtr);
955-
obj->ob_type->tp_free(obj);
955+
Py_TYPE(obj)->tp_free(obj);
956956
}
957957

958958
.. index::
@@ -995,7 +995,7 @@ done. This can be done using the :cfunc:`PyErr_Fetch` and
995995

996996
Py_DECREF(self->my_callback);
997997
}
998-
obj->ob_type->tp_free((PyObject*)self);
998+
Py_TYPE(obj)->tp_free((PyObject*)self);
999999
}
10001000

10011001

0 commit comments

Comments
 (0)