Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 3a45703

Browse files
author
Anselm Kruis
committed
Issue #129: fix calling PyTasklet_New( NULL, ...)
Re-add the test for NULL. It got lost in change 20dad21ded9c (2.7-slp) and dae0e80f141d (3.2-slp). Update the documentation. https://bitbucket.org/stackless-dev/stackless/issues/129 (grafted from a4dfdadc7cf547e7f589e8191b8bab2c67e34f00)
1 parent 2aa8771 commit 3a45703

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Doc/c-api/stackless.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Tasklets
1010

1111
.. c:function:: PyTaskletObject *PyTasklet_New(PyTypeObject *type, PyObject *func)
1212
13-
Return a new tasklet object. *type* must be derived from :c:type:`PyTasklet_Type`
14-
or *NULL*. *func* must be a callable object (normal use-case) or *NULL*, if the
15-
tasklet is being used via capture().
13+
Return a new tasklet object. *type* must be derived from :c:type:`PyTasklet_Type`
14+
or ``NULL``. *func* must be a callable object or ``NULL`` or :c:macro:`Py_None`. If *func*
15+
is ``NULL`` or :c:macro:`Py_None` you must set it later with :c:func:`PyTasklet_BindEx`.
1616
1717
.. todo: in the case where NULL is returned and slp_ensure_linkage fails no
1818
exception is set, which is in contrast elsewhere in the function.

Stackless/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://bitbucket.org/stackless-dev/stackless/issues/129
13+
C-API: Calling PyTasklet_New( NULL, ...) no longer crashes.
14+
1215
- https://bitbucket.org/stackless-dev/stackless/issues/128
1316
Fix pickling of the module 'stackless'.
1417

Stackless/module/taskletobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,14 @@ tasklet_dealloc(PyTaskletObject *t)
216216
PyTaskletObject *
217217
PyTasklet_New(PyTypeObject *type, PyObject *func)
218218
{
219+
if (type == NULL) {
220+
type = &PyTasklet_Type;
221+
}
219222
if (!PyType_IsSubtype(type, &PyTasklet_Type)) {
220223
PyErr_SetNone(PyExc_TypeError);
221224
return NULL;
222225
}
223-
if (func)
226+
if (func && func != Py_None)
224227
return (PyTaskletObject*)PyObject_CallFunctionObjArgs((PyObject*)type, func, NULL);
225228
else
226229
return (PyTaskletObject*)PyObject_CallFunction((PyObject*)type, NULL);

0 commit comments

Comments
 (0)