Skip to content

Commit bc88cc8

Browse files
author
Anselm Kruis
committed
Stackless issue python#191: fix tp_dealloc / tp_new / tp_free usage
Use/implement tp_dealloc/tp_new/tp_free according to the latest C-API documentation.
1 parent f132ddd commit bc88cc8

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

Stackless/core/cframeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cframe_dealloc(PyCFrameObject *cf)
4949
free_list = cf;
5050
}
5151
else
52-
PyObject_GC_Del(cf);
52+
Py_TYPE(cf)->tp_free((PyObject*)cf);
5353
}
5454

5555
static int
@@ -331,7 +331,7 @@ PyTypeObject PyCFrame_Type = {
331331
0, /* tp_init */
332332
0, /* tp_alloc */
333333
cframe_new, /* tp_new */
334-
PyObject_Del, /* tp_free */
334+
PyObject_GC_Del, /* tp_free */
335335
};
336336

337337
int slp_init_cframetype(void)

Stackless/module/scheduling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bomb_dealloc(PyBombObject *bomb)
2929
free_list = bomb;
3030
}
3131
else
32-
PyObject_GC_Del(bomb);
32+
Py_TYPE(bomb)->tp_free((PyObject*)bomb);
3333
}
3434

3535
static int

Stackless/module/stacklessmodule.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ typedef struct PyAtomicObject
4141
int old;
4242
} PyAtomicObject;
4343

44-
static PyObject *
45-
atomic_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
46-
47-
static void
48-
atomic_dealloc(PyObject *self)
49-
{
50-
PyObject_DEL(self);
51-
}
52-
5344
static PyObject *
5445
atomic_enter(PyObject *self)
5546
{
@@ -90,7 +81,7 @@ PyTypeObject PyAtomic_Type = {
9081
"_stackless.atomic",
9182
sizeof(PyAtomicObject),
9283
0,
93-
atomic_dealloc, /* tp_dealloc */
84+
0, /* tp_dealloc */
9485
0, /* tp_print */
9586
0, /* tp_getattr */
9687
0, /* tp_setattr */
@@ -123,16 +114,9 @@ PyTypeObject PyAtomic_Type = {
123114
0, /* tp_dictoffset */
124115
0, /* tp_init */
125116
0, /* tp_alloc */
126-
atomic_new, /* tp_new */
117+
PyType_GenericNew, /* tp_new */
127118
};
128119

129-
static PyObject *
130-
atomic_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
131-
{
132-
PyAtomicObject *a = PyObject_NEW(PyAtomicObject, &PyAtomic_Type);
133-
return (PyObject *)a;
134-
}
135-
136120
/******************************************************
137121
138122
The Stackless Module

0 commit comments

Comments
 (0)