Skip to content

Commit

Permalink
Stackless issue python#265: fix the signature of tp_clear functions
Browse files Browse the repository at this point in the history
Return type is 'int', not 'void'.
  • Loading branch information
Anselm Kruis committed Jun 9, 2021
1 parent 233e873 commit d822483
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Stackless/core/cframeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cframe_traverse(PyCFrameObject *cf, visitproc visit, void *arg)

/* clearing a cframe while the object still exists */

static void
static int
cframe_clear(PyCFrameObject *cf)
{
/* The Python C-API documentation recomends to use Py_CLEAR() to release
Expand All @@ -86,6 +86,7 @@ cframe_clear(PyCFrameObject *cf)
Py_XDECREF(tmp_ob1);
Py_XDECREF(tmp_ob2);
Py_XDECREF(tmp_ob3);
return 0;
}


Expand Down
3 changes: 2 additions & 1 deletion Stackless/module/channelobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ channel_traverse(PyChannelObject *ch, visitproc visit, void *arg)
return 0;
}

static void
static int
channel_clear(PyObject *ob)
{
PyChannelObject *ch = (PyChannelObject *) ob;
Expand All @@ -74,6 +74,7 @@ channel_clear(PyObject *ob)
ob = (PyObject *) slp_channel_remove(ch, NULL, NULL, NULL);
Py_DECREF(ob);
}
return 0;
}

static void
Expand Down
3 changes: 2 additions & 1 deletion Stackless/module/scheduling.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ bomb_traverse(PyBombObject *bomb, visitproc visit, void *arg)
return 0;
}

static void
static int
bomb_clear(PyBombObject *bomb)
{
Py_CLEAR(bomb->curexc_type);
Py_CLEAR(bomb->curexc_value);
Py_CLEAR(bomb->curexc_traceback);
return 0;
}

PyBombObject *
Expand Down
3 changes: 2 additions & 1 deletion Stackless/module/taskletobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exc_state_clear(_PyErr_StackItem *exc_state)
Py_XDECREF(tb);
}

static void
static int
tasklet_clear(PyTaskletObject *t)
{
tasklet_clear_frames(t);
Expand All @@ -219,6 +219,7 @@ tasklet_clear(PyTaskletObject *t)
* the order of calls to tp_clear is undefined.
*/
t->exc_info = &t->exc_state;
return 0;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion Stackless/pickling/prickelpit.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ _wrap_traverse(PyObject *ob, visitproc visit, void *arg)
return ret;
}

static void
static int
_wrap_clear(PyObject *ob)
{
Py_TYPE(ob) = Py_TYPE(ob)->tp_base;
if (Py_TYPE(ob)->tp_clear != NULL)
Py_TYPE(ob)->tp_clear(ob);
return 0;
}


Expand Down

0 comments on commit d822483

Please sign in to comment.