To: vim_dev@googlegroups.com Subject: Patch 8.2.1883 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1883 Problem: Compiler warnings when using Python. Solution: Adjust PyCFunction to also have the second argument. Use "int" return type for some functions. Insert "(void *)" to get rid of the remaining warnings. Files: src/if_py_both.h, src/if_python.c, src/if_python3.c *** ../vim-8.2.1882/src/if_py_both.h 2020-10-11 18:04:58.284030792 +0200 --- src/if_py_both.h 2020-10-21 20:57:42.379092835 +0200 *************** *** 324,330 **** }; static PyObject * ! OutputDir(PyObject *self) { return ObjectDir(self, OutputAttrs); } --- 324,330 ---- }; static PyObject * ! OutputDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, OutputAttrs); } *************** *** 468,497 **** } static PyObject * ! AlwaysNone(PyObject *self UNUSED) { // do nothing Py_INCREF(Py_None); return Py_None; } static PyObject * ! AlwaysFalse(PyObject *self UNUSED) { // do nothing PyObject *ret = Py_False; Py_INCREF(ret); return ret; } static PyObject * ! AlwaysTrue(PyObject *self UNUSED) { // do nothing PyObject *ret = Py_True; Py_INCREF(ret); return ret; } /***************/ --- 468,500 ---- } static PyObject * ! AlwaysNone(PyObject *self UNUSED, PyObject *args UNUSED) { // do nothing Py_INCREF(Py_None); return Py_None; } + #define ALWAYS_NONE AlwaysNone(NULL, NULL) static PyObject * ! AlwaysFalse(PyObject *self UNUSED, PyObject *args UNUSED) { // do nothing PyObject *ret = Py_False; Py_INCREF(ret); return ret; } + #define ALWAYS_FALSE AlwaysFalse(NULL, NULL) static PyObject * ! AlwaysTrue(PyObject *self UNUSED, PyObject *args UNUSED) { // do nothing PyObject *ret = Py_True; Py_INCREF(ret); return ret; } + #define ALWAYS_TRUE AlwaysTrue(NULL, NULL) /***************/ *************** *** 1179,1185 **** } static PyObject * ! Vim_GetPaths(PyObject *self UNUSED) { PyObject *ret; --- 1182,1188 ---- } static PyObject * ! Vim_GetPaths(PyObject *self UNUSED, PyObject *args UNUSED) { PyObject *ret; *************** *** 1209,1215 **** if (!PyArg_ParseTuple(args, "s|O", &fullname, &target)) return NULL; ! if (!(paths = Vim_GetPaths(self))) return NULL; spec = PyObject_CallFunction(py_find_spec, "sOO", fullname, paths, target); --- 1212,1218 ---- if (!PyArg_ParseTuple(args, "s|O", &fullname, &target)) return NULL; ! if (!(paths = Vim_GetPaths(self, NULL))) return NULL; spec = PyObject_CallFunction(py_find_spec, "sOO", fullname, paths, target); *************** *** 1344,1350 **** if (!PyArg_ParseTuple(args, "s", &fullname)) return NULL; ! if (!(new_path = Vim_GetPaths(self))) return NULL; result = find_module(fullname, fullname, new_path); --- 1347,1353 ---- if (!PyArg_ParseTuple(args, "s", &fullname)) return NULL; ! if (!(new_path = Vim_GetPaths(self, NULL))) return NULL; result = find_module(fullname, fullname, new_path); *************** *** 1408,1415 **** {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, {"bindeval", VimEvalPy, METH_O, "Like eval(), but returns objects attached to Vim ones"}, {"strwidth", VimStrwidth, METH_O, "Screen string width, counts as having width 1"}, ! {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, ! {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, {"foreach_rtp", VimForeachRTP, METH_O, "Call given callable for each path in &rtp"}, #if PY_VERSION_HEX >= 0x030700f0 {"find_spec", FinderFindSpec, METH_VARARGS, "Internal use only, returns spec object for any input it receives"}, --- 1411,1418 ---- {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" }, {"bindeval", VimEvalPy, METH_O, "Like eval(), but returns objects attached to Vim ones"}, {"strwidth", VimStrwidth, METH_O, "Screen string width, counts as having width 1"}, ! {"chdir", (PyCFunction)(void *)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, ! {"fchdir", (PyCFunction)(void *)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"}, {"foreach_rtp", VimForeachRTP, METH_O, "Call given callable for each path in &rtp"}, #if PY_VERSION_HEX >= 0x030700f0 {"find_spec", FinderFindSpec, METH_VARARGS, "Internal use only, returns spec object for any input it receives"}, *************** *** 1643,1649 **** }; static PyObject * ! DictionaryDir(PyObject *self) { return ObjectDir(self, DictionaryAttrs); } --- 1646,1652 ---- }; static PyObject * ! DictionaryDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, DictionaryAttrs); } *************** *** 1850,1860 **** dii->dii_todo = ht->ht_used; return IterNew(dii, ! (destructorfun) PyMem_Free, (nextfun) DictionaryIterNext, NULL, NULL, (PyObject *)self); } ! static PyInt DictionaryAssItem( DictionaryObject *self, PyObject *keyObject, PyObject *valObject) { --- 1853,1863 ---- dii->dii_todo = ht->ht_used; return IterNew(dii, ! (destructorfun)(void *) PyMem_Free, (nextfun) DictionaryIterNext, NULL, NULL, (PyObject *)self); } ! static int DictionaryAssItem( DictionaryObject *self, PyObject *keyObject, PyObject *valObject) { *************** *** 1970,1976 **** } static PyObject * ! DictionaryListKeys(DictionaryObject *self) { return DictionaryListObjects(self, dict_key); } --- 1973,1979 ---- } static PyObject * ! DictionaryListKeys(DictionaryObject *self, PyObject *args UNUSED) { return DictionaryListObjects(self, dict_key); } *************** *** 1985,1991 **** } static PyObject * ! DictionaryListValues(DictionaryObject *self) { return DictionaryListObjects(self, dict_val); } --- 1988,1994 ---- } static PyObject * ! DictionaryListValues(DictionaryObject *self, PyObject *args UNUSED) { return DictionaryListObjects(self, dict_val); } *************** *** 2015,2021 **** } static PyObject * ! DictionaryListItems(DictionaryObject *self) { return DictionaryListObjects(self, dict_item); } --- 2018,2024 ---- } static PyObject * ! DictionaryListItems(DictionaryObject *self, PyObject *args UNUSED) { return DictionaryListObjects(self, dict_item); } *************** *** 2166,2172 **** } static PyObject * ! DictionaryPopItem(DictionaryObject *self) { hashitem_T *hi; PyObject *ret; --- 2169,2175 ---- } static PyObject * ! DictionaryPopItem(DictionaryObject *self, PyObject *args UNUSED) { hashitem_T *hi; PyObject *ret; *************** *** 2229,2235 **** {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, {"values", (PyCFunction)DictionaryListValues, METH_NOARGS, ""}, {"items", (PyCFunction)DictionaryListItems, METH_NOARGS, ""}, ! {"update", (PyCFunction)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""}, {"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""}, {"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""}, {"popitem", (PyCFunction)DictionaryPopItem, METH_NOARGS, ""}, --- 2232,2238 ---- {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""}, {"values", (PyCFunction)DictionaryListValues, METH_NOARGS, ""}, {"items", (PyCFunction)DictionaryListItems, METH_NOARGS, ""}, ! {"update", (PyCFunction)(void *)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""}, {"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""}, {"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""}, {"popitem", (PyCFunction)DictionaryPopItem, METH_NOARGS, ""}, *************** *** 2742,2762 **** return 0; } ! static Py_ssize_t ListAssItem(ListObject *self, PyObject *idx, PyObject *obj) { #if PY_MAJOR_VERSION < 3 if (PyInt_Check(idx)) { long _idx = PyInt_AsLong(idx); ! return ListAssIndex(self, _idx, obj); } else #endif if (PyLong_Check(idx)) { long _idx = PyLong_AsLong(idx); ! return ListAssIndex(self, _idx, obj); } else if (PySlice_Check(idx)) { --- 2745,2765 ---- return 0; } ! static int ListAssItem(ListObject *self, PyObject *idx, PyObject *obj) { #if PY_MAJOR_VERSION < 3 if (PyInt_Check(idx)) { long _idx = PyInt_AsLong(idx); ! return (int)ListAssIndex(self, _idx, obj); } else #endif if (PyLong_Check(idx)) { long _idx = PyLong_AsLong(idx); ! return (int)ListAssIndex(self, _idx, obj); } else if (PySlice_Check(idx)) { *************** *** 2765,2771 **** if (PySlice_GetIndicesEx((PySliceObject_T *)idx, ListLength(self), &start, &stop, &step, &slicelen) < 0) return -1; ! return ListAssSlice(self, start, step, slicelen, obj); } else --- 2768,2774 ---- if (PySlice_GetIndicesEx((PySliceObject_T *)idx, ListLength(self), &start, &stop, &step, &slicelen) < 0) return -1; ! return (int)ListAssSlice(self, start, step, slicelen, obj); } else *************** *** 2858,2864 **** }; static PyObject * ! ListDir(PyObject *self) { return ObjectDir(self, ListAttrs); } --- 2861,2867 ---- }; static PyObject * ! ListDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, ListAttrs); } *************** *** 3113,3119 **** }; static PyObject * ! FunctionDir(PyObject *self) { return ObjectDir(self, FunctionAttrs); } --- 3116,3122 ---- }; static PyObject * ! FunctionDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, FunctionAttrs); } *************** *** 3128,3134 **** else if (strcmp(name, "args") == 0) { if (self->argv == NULL || (list = list_alloc()) == NULL) ! return AlwaysNone(NULL); for (i = 0; i < self->argc; ++i) list_append_tv(list, &self->argv[i]); --- 3131,3137 ---- else if (strcmp(name, "args") == 0) { if (self->argv == NULL || (list = list_alloc()) == NULL) ! return ALWAYS_NONE; for (i = 0; i < self->argc; ++i) list_append_tv(list, &self->argv[i]); *************** *** 3136,3147 **** } else if (strcmp(name, "self") == 0) return self->self == NULL ! ? AlwaysNone(NULL) : NEW_DICTIONARY(self->self); else if (strcmp(name, "auto_rebind") == 0) return self->auto_rebind ! ? AlwaysTrue(NULL) ! : AlwaysFalse(NULL); else if (strcmp(name, "__members__") == 0) return ObjectDir(NULL, FunctionAttrs); return NULL; --- 3139,3150 ---- } else if (strcmp(name, "self") == 0) return self->self == NULL ! ? ALWAYS_NONE : NEW_DICTIONARY(self->self); else if (strcmp(name, "auto_rebind") == 0) return self->auto_rebind ! ? ALWAYS_TRUE ! : ALWAYS_FALSE; else if (strcmp(name, "__members__") == 0) return ObjectDir(NULL, FunctionAttrs); return NULL; *************** *** 3497,3503 **** oii->lastoption = NULL; return IterNew(oii, ! (destructorfun) PyMem_Free, (nextfun) OptionsIterNext, NULL, NULL, (PyObject *)self); } --- 3500,3506 ---- oii->lastoption = NULL; return IterNew(oii, ! (destructorfun)(void *) PyMem_Free, (nextfun) OptionsIterNext, NULL, NULL, (PyObject *)self); } *************** *** 3742,3748 **** }; static PyObject * ! TabPageDir(PyObject *self) { return ObjectDir(self, TabPageAttrs); } --- 3745,3751 ---- }; static PyObject * ! TabPageDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, TabPageAttrs); } *************** *** 3968,3974 **** }; static PyObject * ! WindowDir(PyObject *self) { return ObjectDir(self, WindowAttrs); } --- 3971,3977 ---- }; static PyObject * ! WindowDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, WindowAttrs); } *************** *** 5106,5112 **** }; static PyObject * ! RangeDir(PyObject *self) { return ObjectDir(self, RangeAttrs); } --- 5109,5115 ---- }; static PyObject * ! RangeDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, RangeAttrs); } *************** *** 5223,5229 **** }; static PyObject * ! BufferDir(PyObject *self) { return ObjectDir(self, BufferAttrs); } --- 5226,5232 ---- }; static PyObject * ! BufferDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, BufferAttrs); } *************** *** 5520,5526 **** }; static PyObject * ! CurrentDir(PyObject *self) { return ObjectDir(self, CurrentAttrs); } --- 5523,5529 ---- }; static PyObject * ! CurrentDir(PyObject *self, PyObject *args UNUSED) { return ObjectDir(self, CurrentAttrs); } *************** *** 6424,6433 **** case VAR_SPECIAL: switch (tv->vval.v_number) { ! case VVAL_FALSE: return AlwaysFalse(NULL); ! case VVAL_TRUE: return AlwaysTrue(NULL); case VVAL_NONE: ! case VVAL_NULL: return AlwaysNone(NULL); } PyErr_SET_VIM(N_("internal error: invalid value type")); return NULL; --- 6427,6436 ---- case VAR_SPECIAL: switch (tv->vval.v_number) { ! case VVAL_FALSE: return ALWAYS_FALSE; ! case VVAL_TRUE: return ALWAYS_TRUE; case VVAL_NONE: ! case VVAL_NULL: return ALWAYS_NONE; } PyErr_SET_VIM(N_("internal error: invalid value type")); return NULL; *** ../vim-8.2.1882/src/if_python.c 2020-03-29 20:51:03.081780739 +0200 --- src/if_python.c 2020-10-21 20:57:35.383114795 +0200 *************** *** 1197,1212 **** #define BufferType_Check(obj) ((obj)->ob_type == &BufferType) ! static PyInt BufferAssItem(PyObject *, PyInt, PyObject *); ! static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *); // Line range type - Implementation functions // -------------------------------------- #define RangeType_Check(obj) ((obj)->ob_type == &RangeType) ! static PyInt RangeAssItem(PyObject *, PyInt, PyObject *); ! static PyInt RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *); // Current objects type - Implementation functions // ----------------------------------------------- --- 1197,1212 ---- #define BufferType_Check(obj) ((obj)->ob_type == &BufferType) ! static int BufferAssItem(PyObject *, PyInt, PyObject *); ! static int BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *); // Line range type - Implementation functions // -------------------------------------- #define RangeType_Check(obj) ((obj)->ob_type == &RangeType) ! static int RangeAssItem(PyObject *, PyInt, PyObject *); ! static int RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *); // Current objects type - Implementation functions // ----------------------------------------------- *************** *** 1246,1258 **** ////////////////// ! static PyInt BufferAssItem(PyObject *self, PyInt n, PyObject *val) { return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL); } ! static PyInt BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val) { return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL); --- 1246,1258 ---- ////////////////// ! static int BufferAssItem(PyObject *self, PyInt n, PyObject *val) { return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL); } ! static int BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val) { return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL); *************** *** 1290,1296 **** //////////////// ! static PyInt RangeAssItem(PyObject *self, PyInt n, PyObject *val) { return RBAsItem(((RangeObject *)(self))->buf, n, val, --- 1290,1296 ---- //////////////// ! static int RangeAssItem(PyObject *self, PyInt n, PyObject *val) { return RBAsItem(((RangeObject *)(self))->buf, n, val, *************** *** 1299,1305 **** &((RangeObject *)(self))->end); } ! static PyInt RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val) { return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val, --- 1299,1305 ---- &((RangeObject *)(self))->end); } ! static int RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val) { return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val, *** ../vim-8.2.1882/src/if_python3.c 2020-10-11 18:04:58.284030792 +0200 --- src/if_python3.c 2020-10-21 20:27:32.484513133 +0200 *************** *** 1252,1258 **** #define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType) static PyObject* BufferSubscript(PyObject *self, PyObject *idx); ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val); // Line range type - Implementation functions // -------------------------------------- --- 1252,1258 ---- #define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType) static PyObject* BufferSubscript(PyObject *self, PyObject *idx); ! static int BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val); // Line range type - Implementation functions // -------------------------------------- *************** *** 1260,1267 **** #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType) static PyObject* RangeSubscript(PyObject *self, PyObject *idx); ! static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *); ! static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val); // Current objects type - Implementation functions // ----------------------------------------------- --- 1260,1267 ---- #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType) static PyObject* RangeSubscript(PyObject *self, PyObject *idx); ! static int RangeAsItem(PyObject *, Py_ssize_t, PyObject *); ! static int RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val); // Current objects type - Implementation functions // ----------------------------------------------- *************** *** 1346,1352 **** } } ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val) { if (PyLong_Check(idx)) --- 1346,1352 ---- } } ! static int BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val) { if (PyLong_Check(idx)) *************** *** 1418,1424 **** //////////////// ! static Py_ssize_t RangeAsItem(PyObject *self, Py_ssize_t n, PyObject *val) { return RBAsItem(((RangeObject *)(self))->buf, n, val, --- 1418,1424 ---- //////////////// ! static int RangeAsItem(PyObject *self, Py_ssize_t n, PyObject *val) { return RBAsItem(((RangeObject *)(self))->buf, n, val, *************** *** 1461,1467 **** } } ! static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val) { if (PyLong_Check(idx)) --- 1461,1467 ---- } } ! static int RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val) { if (PyLong_Check(idx)) *** ../vim-8.2.1882/src/version.c 2020-10-21 20:58:47.714889960 +0200 --- src/version.c 2020-10-21 20:59:34.942745602 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1883, /**/ -- hundred-and-one symptoms of being an internet addict: 101. U can read htis w/o ny porblm and cant figur eout Y its evn listd. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///