Skip to content

Commit cd48a58

Browse files
Anselm Kruisakruis
authored andcommitted
Stackless issue python#265: add missing arguments to C-function definitions
Most (getter)-functions, (setter)-functions and (PyCFunction)-functions with flag METH_NOARGS lack an unused last argument, "void *" for (getter) and (setter), "PyObject *" for (PyCFunction)-functions. This commit adds these arguments.
1 parent f3739b9 commit cd48a58

File tree

7 files changed

+79
-74
lines changed

7 files changed

+79
-74
lines changed

Include/internal/pycore_stackless.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ PyObject* slp_context_run_callback(PyFrameObject *f, int exc, PyObject *result);
780780
(ts->st.runflags & PY_WATCHDOG_IGNORE_NESTING))
781781

782782
/* Interpreter shutdown and thread state access */
783-
PyObject * slp_getthreads(PyObject *self);
783+
PyObject * slp_getthreads(PyObject *self, PyObject *unused);
784784
void slp_head_lock(void);
785785
void slp_head_unlock(void);
786786
#define SLP_HEAD_LOCK() slp_head_lock()

Modules/_pickle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,7 +4689,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj, void *Py_UNUSED(ignored))
46894689

46904690
#ifdef STACKLESS
46914691
static PyObject *
4692-
Pickler_get_module_dict_ids(PicklerObject *p)
4692+
Pickler_get_module_dict_ids(PicklerObject *p, void *closure)
46934693
{
46944694
if (p->module_dict_ids == NULL)
46954695
PyErr_SetString(PyExc_AttributeError, "module_dict_ids");
@@ -4699,7 +4699,7 @@ Pickler_get_module_dict_ids(PicklerObject *p)
46994699
}
47004700

47014701
static int
4702-
Pickler_set_module_dict_ids(PicklerObject *p, PyObject *v)
4702+
Pickler_set_module_dict_ids(PicklerObject *p, PyObject *v, void *closure)
47034703
{
47044704
if (v == NULL) {
47054705
PyErr_SetString(PyExc_TypeError,

Stackless/changelog.txt

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

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

12+
- https://github.com/stackless-dev/stackless/issues/265
13+
Most (getter)-functions, (setter)-functions and (PyCFunction)-functions with
14+
flag METH_NOARGS used to lack an unused last argument, "void *" for (getter)
15+
and (setter), "PyObject *" for (PyCFunction)-functions.
16+
1217
- https://github.com/stackless-dev/stackless/issues/265
1318
Avoid undefined behavior, if Stackless classes implement __reduce__() and
1419
__reduce_ex__() using a single C-function.

Stackless/module/channelobject.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ channel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
196196
}
197197

198198
static PyObject *
199-
channel_get_queue(PyChannelObject *self)
199+
channel_get_queue(PyChannelObject *self, void *closure)
200200
{
201201
PyObject *ret = (PyObject*) self->head;
202202

@@ -209,11 +209,11 @@ channel_get_queue(PyChannelObject *self)
209209
PyObject *
210210
PyChannel_GetQueue(PyChannelObject *self)
211211
{
212-
return channel_get_queue(self);
212+
return channel_get_queue(self, NULL);
213213
}
214214

215215
static PyObject *
216-
channel_get_closing(PyChannelObject *self)
216+
channel_get_closing(PyChannelObject *self, void *closure)
217217
{
218218
return PyBool_FromLong(self->flags.closing);
219219
}
@@ -225,7 +225,7 @@ PyChannel_GetClosing(PyChannelObject *self)
225225
}
226226

227227
static PyObject *
228-
channel_get_closed(PyChannelObject *self)
228+
channel_get_closed(PyChannelObject *self, void *closure)
229229
{
230230
return PyBool_FromLong(self->flags.closing && self->balance == 0);
231231
}
@@ -238,13 +238,13 @@ PyChannel_GetClosed(PyChannelObject *self)
238238

239239

240240
static PyObject *
241-
channel_get_preference(PyChannelObject *self)
241+
channel_get_preference(PyChannelObject *self, void *closure)
242242
{
243243
return PyLong_FromLong(self->flags.preference);
244244
}
245245

246246
static int
247-
channel_set_preference(PyChannelObject *self, PyObject *value)
247+
channel_set_preference(PyChannelObject *self, PyObject *value, void *closure)
248248
{
249249
int val;
250250

@@ -268,13 +268,13 @@ PyChannel_SetPreference(PyChannelObject *self, int val)
268268
}
269269

270270
static PyObject *
271-
channel_get_schedule_all(PyChannelObject *self)
271+
channel_get_schedule_all(PyChannelObject *self, void *closure)
272272
{
273273
return PyLong_FromLong(self->flags.schedule_all);
274274
}
275275

276276
static int
277-
channel_set_schedule_all(PyChannelObject *self, PyObject *value)
277+
channel_set_schedule_all(PyChannelObject *self, PyObject *value, void *closure)
278278
{
279279
if (!PyLong_Check(value))
280280
TYPE_ERROR("preference must be set to a bool or integer", -1);
@@ -819,7 +819,7 @@ PyChannel_Receive(PyChannelObject *self)
819819
}
820820

821821
static PyObject *
822-
channel_receive(PyObject *self)
822+
channel_receive(PyObject *self, PyObject *unused)
823823
{
824824
return impl_channel_receive((PyChannelObject*)self);
825825
}
@@ -1069,7 +1069,7 @@ If the channel is not empty, the flag 'closing' becomes true.\n\
10691069
If the channel is empty, the flag 'closed' becomes true.");
10701070

10711071
static PyObject *
1072-
channel_close(PyChannelObject *self)
1072+
channel_close(PyChannelObject *self, PyObject *unused)
10731073
{
10741074
self->flags.closing = 1;
10751075

@@ -1087,7 +1087,7 @@ PyDoc_STRVAR(channel_open__doc__,
10871087
"channel.open() -- reopen a channel. See channel.close.");
10881088

10891089
static PyObject *
1090-
channel_open(PyChannelObject *self)
1090+
channel_open(PyChannelObject *self, PyObject *unused)
10911091
{
10921092
self->flags.closing = 0;
10931093

Stackless/module/stacklessmodule.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct PyAtomicObject
4040
} PyAtomicObject;
4141

4242
static PyObject *
43-
atomic_enter(PyObject *self)
43+
atomic_enter(PyObject *self, PyObject *unused)
4444
{
4545
PyAtomicObject *a = (PyAtomicObject*)self;
4646
PyObject *c = PyStackless_GetCurrent();
@@ -333,7 +333,7 @@ PyStackless_GetRunCount(void)
333333
}
334334

335335
static PyObject *
336-
getruncount(PyObject *self)
336+
getruncount(PyObject *self, PyObject *unused)
337337
{
338338
PyThreadState *ts = _PyThreadState_GET();
339339
return PyLong_FromLong(ts->st.runcount);
@@ -360,7 +360,7 @@ PyStackless_GetCurrent(void)
360360
}
361361

362362
static PyObject *
363-
getcurrent(PyObject *self)
363+
getcurrent(PyObject *self, PyObject *unused)
364364
{
365365
return PyStackless_GetCurrent();
366366
}
@@ -398,7 +398,7 @@ PyStackless_GetCurrentId(void)
398398
}
399399

400400
static PyObject *
401-
getcurrentid(PyObject *self)
401+
getcurrentid(PyObject *self, PyObject *unused)
402402
{
403403
return PyLong_FromUnsignedLong(PyStackless_GetCurrentId());
404404
}
@@ -407,7 +407,7 @@ PyDoc_STRVAR(getmain__doc__,
407407
"getmain() -- return the main tasklet of this thread.");
408408

409409
static PyObject *
410-
getmain(PyObject *self)
410+
getmain(PyObject *self, PyObject *unused)
411411
{
412412
PyThreadState *ts = _PyThreadState_GET();
413413
PyObject * t = (PyObject*) ts->st.main;
@@ -972,7 +972,7 @@ This can be used to measure the execution time of 1.000.000 switches.");
972972

973973
static
974974
PyObject *
975-
_test_outside(PyObject *self)
975+
_test_outside(PyObject *self, PyObject *unused)
976976
{
977977
PyThreadState *ts = _PyThreadState_GET();
978978
PyTaskletObject *stmain = ts->st.main;
@@ -1378,7 +1378,7 @@ PyDoc_STRVAR(get_schedule_callback__doc__,
13781378
This function returns None, if no callback is installed.");
13791379

13801380
static PyObject *
1381-
get_schedule_callback(PyObject *self)
1381+
get_schedule_callback(PyObject *self, PyObject *unused)
13821382
{
13831383
PyThreadState * ts = _PyThreadState_GET();
13841384
PyObject *temp = ts->interp->st.schedule_hook;
@@ -1419,7 +1419,7 @@ PyDoc_STRVAR(get_channel_callback__doc__,
14191419
This function returns None, if no callback is installed.");
14201420

14211421
static PyObject *
1422-
get_channel_callback(PyObject *self)
1422+
get_channel_callback(PyObject *self, PyObject *unused)
14231423
{
14241424
PyObject *temp = slp_get_channel_callback();
14251425
if (NULL == temp) {
@@ -1498,7 +1498,7 @@ PyDoc_STRVAR(_get_refinfo__doc__,
14981498
"refcount, ref_total, computed total)");
14991499

15001500
static PyObject *
1501-
_get_refinfo(PyObject *self)
1501+
_get_refinfo(PyObject *self, PyObject *unused)
15021502
{
15031503
PyObject *op, *max = Py_None;
15041504
PyObject *refchain;
@@ -1524,7 +1524,7 @@ PyDoc_STRVAR(_get_all_objects__doc__,
15241524
"_get_all_objects -- return a list with all objects but the list.");
15251525

15261526
static PyObject *
1527-
_get_all_objects(PyObject *self)
1527+
_get_all_objects(PyObject *self, PyObject *unused)
15281528
{
15291529
PyObject *lis, *ob;
15301530
lis = PyList_New(0);
@@ -1576,7 +1576,7 @@ PyDoc_STRVAR(_gc_untrack__doc__,
15761576
"_gc_untrack, gc_track -- remove or add an object from the gc list.");
15771577

15781578
static PyObject *
1579-
slpmodule_getdebug(PyObject *self)
1579+
slpmodule_getdebug(PyObject *self, PyObject *unused)
15801580
{
15811581
#ifdef _DEBUG
15821582
PyObject *ret = Py_True;
@@ -1591,7 +1591,7 @@ PyDoc_STRVAR(slpmodule_getdebug__doc__,
15911591
"Returns True if this is a DEBUG build");
15921592

15931593
static PyObject *
1594-
slpmodule_getuncollectables(PyObject *self)
1594+
slpmodule_getuncollectables(PyObject *self, PyObject *unused)
15951595
{
15961596
PyThreadState * ts = _PyThreadState_GET();
15971597
PyObject *lis = PyList_New(0);
@@ -1619,7 +1619,7 @@ since their C stack might prevent garbage collection.\n\
16191619
Note that a tasklet is reported for every C stacks it has.");
16201620

16211621
PyObject *
1622-
slp_getthreads(PyObject *self)
1622+
slp_getthreads(PyObject *self, PyObject *unused)
16231623
{
16241624
PyObject *lis = PyList_New(0);
16251625
PyThreadState *ts = _PyThreadState_GET();

0 commit comments

Comments
 (0)