GeezerVison is showing github.com — Stackless issue #265: Fix (invalid) function cast warnings with gcc 8 · akruis/cpython@b73166e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Include/internal/pycore_stackless.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -780,7 +780,7 @@ PyObject* slp_context_run_callback(PyFrameObject *f, int exc, PyObject *result); | 780 | 780 | (ts->st.runflags & PY_WATCHDOG_IGNORE_NESTING)) | 781 | 781 |
| 782 | 782 | /* Interpreter shutdown and thread state access */ | 783 | | -PyObject * slp_getthreads(PyObject *self); | | 783 | +PyObject * slp_getthreads(PyObject *self, PyObject *unused); | 784 | 784 | void slp_head_lock(void); | 785 | 785 | void slp_head_unlock(void); | 786 | 786 | #define SLP_HEAD_LOCK() slp_head_lock() | |
Collapse file Copy file name to clipboardExpand all lines: Modules/_pickle.c +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4689,7 +4689,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj, void *Py_UNUSED(ignored)) | 4689 | 4689 |
| 4690 | 4690 | #ifdef STACKLESS | 4691 | 4691 | static PyObject * | 4692 | | -Pickler_get_module_dict_ids(PicklerObject *p) | | 4692 | +Pickler_get_module_dict_ids(PicklerObject *p, void *closure) | 4693 | 4693 | { | 4694 | 4694 | if (p->module_dict_ids == NULL) | 4695 | 4695 | PyErr_SetString(PyExc_AttributeError, "module_dict_ids"); | @@ -4699,7 +4699,7 @@ Pickler_get_module_dict_ids(PicklerObject *p) | 4699 | 4699 | } | 4700 | 4700 |
| 4701 | 4701 | static int | 4702 | | -Pickler_set_module_dict_ids(PicklerObject *p, PyObject *v) | | 4702 | +Pickler_set_module_dict_ids(PicklerObject *p, PyObject *v, void *closure) | 4703 | 4703 | { | 4704 | 4704 | if (v == NULL) { | 4705 | 4705 | PyErr_SetString(PyExc_TypeError, | |
Collapse file Copy file name to clipboardExpand all lines: Stackless/changelog.txt +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,26 @@ What's New in Stackless 3.X.X? | 9 | 9 |
| 10 | 10 | *Release date: 20XX-XX-XX* | 11 | 11 |
| | 12 | +- https://github.com/stackless-dev/stackless/issues/265 | | 13 | + Fix invalid function cast warnings with gcc 8 for method conventions | | 14 | + different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic | | 15 | + generated code. | | 16 | + | | 17 | +- https://github.com/stackless-dev/stackless/issues/265 | | 18 | + Most (getter)-functions, (setter)-functions and (PyCFunction)-functions with | | 19 | + flag METH_NOARGS used to lack an unused last argument, "void *" for (getter) | | 20 | + and (setter), "PyObject *" for (PyCFunction)-functions. | | 21 | + | | 22 | +- https://github.com/stackless-dev/stackless/issues/265 | | 23 | + Avoid undefined behavior, if Stackless classes implement __reduce__() and | | 24 | + __reduce_ex__() using a single C-function. | | 25 | + | | 26 | +- https://github.com/stackless-dev/stackless/issues/265 | | 27 | + Fix C-API functions PyChannel_Send(), PyChannel_Send_nr(), | | 28 | + PyChannel_Receive(), PyChannel_Receive_nr(), and | | 29 | + PyObject_Call(&PyTasklet_Type, PyObject *args, PyObject *kwargs) if called | | 30 | + from outside of the interpreter (with no main-tasklet). | | 31 | + | 12 | 32 | - https://github.com/stackless-dev/stackless/issues/264 | 13 | 33 | Implement bpo-35134 for Stackless: move header Include/slp_tstate.h to | 14 | 34 | Include/cpython/slp_tstate.h. | |
Collapse file Copy file name to clipboardExpand all lines: Stackless/core/cframeobject.c +16-5Lines changed: 16 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,7 +66,7 @@ cframe_traverse(PyCFrameObject *cf, visitproc visit, void *arg) | 66 | 66 |
| 67 | 67 | /* clearing a cframe while the object still exists */ | 68 | 68 |
| 69 | | -static void | | 69 | +static int | 70 | 70 | cframe_clear(PyCFrameObject *cf) | 71 | 71 | { | 72 | 72 | /* The Python C-API documentation recomends to use Py_CLEAR() to release | @@ -86,6 +86,7 @@ cframe_clear(PyCFrameObject *cf) | 86 | 86 | Py_XDECREF(tmp_ob1); | 87 | 87 | Py_XDECREF(tmp_ob2); | 88 | 88 | Py_XDECREF(tmp_ob3); | | 89 | + return 0; | 89 | 90 | } | 90 | 91 |
| 91 | 92 |
| @@ -133,14 +134,19 @@ static PyObject * execute_soft_switchable_func(PyFrameObject *, int, PyObject *) | 133 | 134 | SLP_DEF_INVALID_EXEC(execute_soft_switchable_func) | 134 | 135 |
| 135 | 136 | static PyObject * | 136 | | -cframe_reduce(PyCFrameObject *cf) | | 137 | +cframe_reduce(PyCFrameObject *cf, PyObject *value) | 137 | 138 | { | 138 | 139 | PyObject *res = NULL, *exec_name = NULL; | 139 | 140 | PyObject *params = NULL; | 140 | 141 | int valid = 1; | 141 | 142 | PyObject *obs[3]; | 142 | 143 | long i, n; | 143 | 144 |
| | 145 | + if (value && !PyLong_Check(value)) { | | 146 | + PyErr_SetString(PyExc_TypeError, "__reduce_ex__ argument should be an integer"); | | 147 | + return NULL; | | 148 | + } | | 149 | + | 144 | 150 | if (cf->f_execute == execute_soft_switchable_func) { | 145 | 151 | exec_name = (PyObject *) cf->any2; | 146 | 152 | assert(cf->any2); | @@ -240,7 +246,7 @@ cframe_setstate(PyObject *self, PyObject *args) | 240 | 246 |
| 241 | 247 | static PyMethodDef cframe_methods[] = { | 242 | 248 | {"__reduce__", (PyCFunction)cframe_reduce, METH_NOARGS, NULL}, | 243 | | - {"__reduce_ex__", (PyCFunction)cframe_reduce, METH_VARARGS, NULL}, | | 249 | + {"__reduce_ex__", (PyCFunction)cframe_reduce, METH_O, NULL}, | 244 | 250 | {"__setstate__", (PyCFunction)cframe_setstate, METH_O, NULL}, | 245 | 251 | {NULL, NULL} | 246 | 252 | }; | @@ -386,8 +392,13 @@ slp_cframe_fini(void) | 386 | 392 | */ | 387 | 393 |
| 388 | 394 | static PyObject * | 389 | | -function_declaration_reduce(PyStacklessFunctionDeclarationObject *self) | | 395 | +function_declaration_reduce(PyStacklessFunctionDeclarationObject *self, PyObject *value) | 390 | 396 | { | | 397 | + if (value && !PyLong_Check(value)) { | | 398 | + PyErr_SetString(PyExc_TypeError, "__reduce_ex__ argument should be an integer"); | | 399 | + return NULL; | | 400 | + } | | 401 | + | 391 | 402 | if (self->name == NULL || *self->name == '\0') { | 392 | 403 | PyErr_SetString(PyExc_SystemError, "no function name"); | 393 | 404 | return NULL; | @@ -397,7 +408,7 @@ function_declaration_reduce(PyStacklessFunctionDeclarationObject *self) | 397 | 408 |
| 398 | 409 | static PyMethodDef function_declaration_methods[] = { | 399 | 410 | {"__reduce__", (PyCFunction)function_declaration_reduce, METH_NOARGS, NULL}, | 400 | | - {"__reduce_ex__", (PyCFunction)function_declaration_reduce, METH_VARARGS, NULL}, | | 411 | + {"__reduce_ex__", (PyCFunction)function_declaration_reduce, METH_O, NULL}, | 401 | 412 | {NULL, NULL} | 402 | 413 | }; | 403 | 414 |
| |
Collapse file Copy file name to clipboardExpand all lines: Stackless/module/_teststackless.c +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -494,11 +494,11 @@ static PyObject* test_PyEval_EvalFrameEx(PyObject *self, PyObject *args, PyObjec | 494 | 494 | static PyMethodDef _teststackless_methods[] = { | 495 | 495 | {"softswitchablefunc", _teststackless_softswitchabledemo, METH_VARARGS | METH_STACKLESS, | 496 | 496 | _teststackless_softswitchabledemo_doc}, | 497 | | - { "test_cframe", (PyCFunction) test_cframe, METH_VARARGS | METH_KEYWORDS, | | 497 | + { "test_cframe", (PyCFunction)(void(*)(void))test_cframe, METH_VARARGS | METH_KEYWORDS, | 498 | 498 | test_cframe__doc__ }, | 499 | 499 | { "test_cstate", (PyCFunction) test_cstate, METH_O, | 500 | 500 | test_cstate__doc__ }, | 501 | | - { "test_PyEval_EvalFrameEx", (PyCFunction) test_PyEval_EvalFrameEx, METH_VARARGS | METH_KEYWORDS, | | 501 | + { "test_PyEval_EvalFrameEx", (PyCFunction)(void(*)(void))test_PyEval_EvalFrameEx, METH_VARARGS | METH_KEYWORDS, | 502 | 502 | test_PyEval_EvalFrameEx__doc__ }, | 503 | 503 | {NULL, NULL} /* sentinel */ | 504 | 504 | }; | |
Collapse file Copy file name to clipboardExpand all lines: Stackless/module/channelobject.c +31-16Lines changed: 31 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,7 @@ channel_traverse(PyChannelObject *ch, visitproc visit, void *arg) | 56 | 56 | return 0; | 57 | 57 | } | 58 | 58 |
| 59 | | -static void | | 59 | +static int | 60 | 60 | channel_clear(PyObject *ob) | 61 | 61 | { | 62 | 62 | PyChannelObject *ch = (PyChannelObject *) ob; | @@ -74,6 +74,7 @@ channel_clear(PyObject *ob) | 74 | 74 | ob = (PyObject *) slp_channel_remove(ch, NULL, NULL, NULL); | 75 | 75 | Py_DECREF(ob); | 76 | 76 | } | | 77 | + return 0; | 77 | 78 | } | 78 | 79 |
| 79 | 80 | static void | @@ -195,7 +196,7 @@ channel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | 195 | 196 | } | 196 | 197 |
| 197 | 198 | static PyObject * | 198 | | -channel_get_queue(PyChannelObject *self) | | 199 | +channel_get_queue(PyChannelObject *self, void *closure) | 199 | 200 | { | 200 | 201 | PyObject *ret = (PyObject*) self->head; | 201 | 202 |
| @@ -208,11 +209,11 @@ channel_get_queue(PyChannelObject *self) | 208 | 209 | PyObject * | 209 | 210 | PyChannel_GetQueue(PyChannelObject *self) | 210 | 211 | { | 211 | | - return channel_get_queue(self); | | 212 | + return channel_get_queue(self, NULL); | 212 | 213 | } | 213 | 214 |
| 214 | 215 | static PyObject * | 215 | | -channel_get_closing(PyChannelObject *self) | | 216 | +channel_get_closing(PyChannelObject *self, void *closure) | 216 | 217 | { | 217 | 218 | return PyBool_FromLong(self->flags.closing); | 218 | 219 | } | @@ -224,7 +225,7 @@ PyChannel_GetClosing(PyChannelObject *self) | 224 | 225 | } | 225 | 226 |
| 226 | 227 | static PyObject * | 227 | | -channel_get_closed(PyChannelObject *self) | | 228 | +channel_get_closed(PyChannelObject *self, void *closure) | 228 | 229 | { | 229 | 230 | return PyBool_FromLong(self->flags.closing && self->balance == 0); | 230 | 231 | } | @@ -237,13 +238,13 @@ PyChannel_GetClosed(PyChannelObject *self) | 237 | 238 |
| 238 | 239 |
| 239 | 240 | static PyObject * | 240 | | -channel_get_preference(PyChannelObject *self) | | 241 | +channel_get_preference(PyChannelObject *self, void *closure) | 241 | 242 | { | 242 | 243 | return PyLong_FromLong(self->flags.preference); | 243 | 244 | } | 244 | 245 |
| 245 | 246 | static int | 246 | | -channel_set_preference(PyChannelObject *self, PyObject *value) | | 247 | +channel_set_preference(PyChannelObject *self, PyObject *value, void *closure) | 247 | 248 | { | 248 | 249 | int val; | 249 | 250 |
| @@ -267,13 +268,13 @@ PyChannel_SetPreference(PyChannelObject *self, int val) | 267 | 268 | } | 268 | 269 |
| 269 | 270 | static PyObject * | 270 | | -channel_get_schedule_all(PyChannelObject *self) | | 271 | +channel_get_schedule_all(PyChannelObject *self, void *closure) | 271 | 272 | { | 272 | 273 | return PyLong_FromLong(self->flags.schedule_all); | 273 | 274 | } | 274 | 275 |
| 275 | 276 | static int | 276 | | -channel_set_schedule_all(PyChannelObject *self, PyObject *value) | | 277 | +channel_set_schedule_all(PyChannelObject *self, PyObject *value, void *closure) | 277 | 278 | { | 278 | 279 | if (!PyLong_Check(value)) | 279 | 280 | TYPE_ERROR("preference must be set to a bool or integer", -1); | @@ -425,10 +426,13 @@ the sender will be blocked. Otherwise, the receiver will\n\ | 425 | 426 | be activated immediately, and the sender is put at the end of\n\ | 426 | 427 | the runnables list."); | 427 | 428 |
| | 429 | +static PyObject * | | 430 | +impl_channel_send(PyChannelObject *self, PyObject *arg); | | 431 | + | 428 | 432 | static PyObject * | 429 | 433 | PyChannel_Send_M(PyChannelObject *self, PyObject *arg) | 430 | 434 | { | 431 | | - PyMethodDef def = {"send", (PyCFunction)PyChannel_Send, METH_O}; | | 435 | + PyMethodDef def = {"send", (PyCFunction)impl_channel_send, METH_O}; | 432 | 436 | return PyStackless_CallCMethod_Main(&def, (PyObject *) self, "O", arg); | 433 | 437 | } | 434 | 438 |
| @@ -770,10 +774,16 @@ continue immediately, and the sender is put at the end of\n\ | 770 | 774 | the runnables list.\n\ | 771 | 775 | The above policy can be changed by setting channel flags."); | 772 | 776 |
| | 777 | +static PyObject * | | 778 | +PyChannel_Receive_cfunc(PyChannelObject *self, PyObject *unused) | | 779 | +{ | | 780 | + return PyChannel_Receive(self); | | 781 | +} | | 782 | + | 773 | 783 | static PyObject * | 774 | 784 | PyChannel_Receive_M(PyChannelObject *self) | 775 | 785 | { | 776 | | - PyMethodDef def = {"receive", (PyCFunction)PyChannel_Receive, METH_NOARGS}; | | 786 | + PyMethodDef def = {"receive", (PyCFunction)PyChannel_Receive_cfunc, METH_NOARGS}; | 777 | 787 | return PyStackless_CallCMethod_Main(&def, (PyObject *) self, NULL); | 778 | 788 | } | 779 | 789 |
| @@ -809,7 +819,7 @@ PyChannel_Receive(PyChannelObject *self) | 809 | 819 | } | 810 | 820 |
| 811 | 821 | static PyObject * | 812 | | -channel_receive(PyObject *self) | | 822 | +channel_receive(PyObject *self, PyObject *unused) | 813 | 823 | { | 814 | 824 | return impl_channel_receive((PyChannelObject*)self); | 815 | 825 | } | @@ -1059,7 +1069,7 @@ If the channel is not empty, the flag 'closing' becomes true.\n\ | 1059 | 1069 | If the channel is empty, the flag 'closed' becomes true."); | 1060 | 1070 |
| 1061 | 1071 | static PyObject * | 1062 | | -channel_close(PyChannelObject *self) | | 1072 | +channel_close(PyChannelObject *self, PyObject *unused) | 1063 | 1073 | { | 1064 | 1074 | self->flags.closing = 1; | 1065 | 1075 |
| @@ -1077,7 +1087,7 @@ PyDoc_STRVAR(channel_open__doc__, | 1077 | 1087 | "channel.open() -- reopen a channel. See channel.close."); | 1078 | 1088 |
| 1079 | 1089 | static PyObject * | 1080 | | -channel_open(PyChannelObject *self) | | 1090 | +channel_open(PyChannelObject *self, PyObject *unused) | 1081 | 1091 | { | 1082 | 1092 | self->flags.closing = 0; | 1083 | 1093 |
| @@ -1095,12 +1105,17 @@ PyDoc_STRVAR(channel_reduce__doc__, | 1095 | 1105 | "channel.__reduce__() -- currently does not distinguish threads."); | 1096 | 1106 |
| 1097 | 1107 | static PyObject * | 1098 | | -channel_reduce(PyChannelObject * ch) | | 1108 | +channel_reduce(PyChannelObject * ch, PyObject *value) | 1099 | 1109 | { | 1100 | 1110 | PyObject *tup = NULL, *lis = NULL; | 1101 | 1111 | PyTaskletObject *t; | 1102 | 1112 | int i, n; | 1103 | 1113 |
| | 1114 | + if (value && !PyLong_Check(value)) { | | 1115 | + PyErr_SetString(PyExc_TypeError, "__reduce_ex__ argument should be an integer"); | | 1116 | + return NULL; | | 1117 | + } | | 1118 | + | 1104 | 1119 | lis = PyList_New(0); | 1105 | 1120 | if (lis == NULL) goto err_exit; | 1106 | 1121 | t = ch->head; | @@ -1179,7 +1194,7 @@ channel_methods[] = { | 1179 | 1194 | channel_open__doc__}, | 1180 | 1195 | {"__reduce__", (PCF)channel_reduce, METH_NOARGS, | 1181 | 1196 | channel_reduce__doc__}, | 1182 | | - {"__reduce_ex__", (PCF)channel_reduce, METH_VARARGS, | | 1197 | + {"__reduce_ex__", (PCF)channel_reduce, METH_O, | 1183 | 1198 | channel_reduce__doc__}, | 1184 | 1199 | {"__setstate__", (PCF)channel_setstate, METH_O, | 1185 | 1200 | channel_setstate__doc__}, | |
Collapse file Copy file name to clipboardExpand all lines: Stackless/module/scheduling.c +9-3Lines changed: 9 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,12 +42,13 @@ bomb_traverse(PyBombObject *bomb, visitproc visit, void *arg) | 42 | 42 | return 0; | 43 | 43 | } | 44 | 44 |
| 45 | | -static void | | 45 | +static int | 46 | 46 | bomb_clear(PyBombObject *bomb) | 47 | 47 | { | 48 | 48 | Py_CLEAR(bomb->curexc_type); | 49 | 49 | Py_CLEAR(bomb->curexc_value); | 50 | 50 | Py_CLEAR(bomb->curexc_traceback); | | 51 | + return 0; | 51 | 52 | } | 52 | 53 |
| 53 | 54 | PyBombObject * | @@ -216,10 +217,15 @@ slp_bomb_explode(PyObject *_bomb) | 216 | 217 | } | 217 | 218 |
| 218 | 219 | static PyObject * | 219 | | -bomb_reduce(PyBombObject *bomb) | | 220 | +bomb_reduce(PyBombObject *bomb, PyObject *value) | 220 | 221 | { | 221 | 222 | PyObject *tup; | 222 | 223 |
| | 224 | + if (value && !PyLong_Check(value)) { | | 225 | + PyErr_SetString(PyExc_TypeError, "__reduce_ex__ argument should be an integer"); | | 226 | + return NULL; | | 227 | + } | | 228 | + | 223 | 229 | tup = slp_into_tuple_with_nulls(&bomb->curexc_type, 3); | 224 | 230 | if (tup != NULL) | 225 | 231 | tup = Py_BuildValue("(O()O)", &PyBomb_Type, tup); | @@ -246,7 +252,7 @@ static PyMemberDef bomb_members[] = { | 246 | 252 |
| 247 | 253 | static PyMethodDef bomb_methods[] = { | 248 | 254 | {"__reduce__", (PyCFunction)bomb_reduce, METH_NOARGS}, | 249 | | - {"__reduce_ex__", (PyCFunction)bomb_reduce, METH_VARARGS}, | | 255 | + {"__reduce_ex__", (PyCFunction)bomb_reduce, METH_O}, | 250 | 256 | {"__setstate__", (PyCFunction)bomb_setstate, METH_O}, | 251 | 257 | {NULL, NULL} /* sentinel */ | 252 | 258 | }; | |
|