| To: vim_dev@googlegroups.com |
| Subject: Patch 7.3.907 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 7.3.907 |
| Problem: Python uses IndexError when a dict key is not found. |
| Solution: Use KeyError instead. (ZyX) |
| Files: src/if_py_both.h, src/if_python3.c, src/if_python.c, |
| src/testdir/test86.ok, src/testdir/test87.ok |
| |
| |
| |
| |
| |
| *** 861,867 **** |
| |
| if (di == NULL) |
| { |
| ! PyErr_SetString(PyExc_IndexError, _("no such key in dictionary")); |
| return NULL; |
| } |
| |
| --- 861,867 ---- |
| |
| if (di == NULL) |
| { |
| ! PyErr_SetString(PyExc_KeyError, _("no such key in dictionary")); |
| return NULL; |
| } |
| |
| |
| |
| |
| *** 327,338 **** |
| --- 327,340 ---- |
| /* Imported exception objects */ |
| static PyObject *p3imp_PyExc_AttributeError; |
| static PyObject *p3imp_PyExc_IndexError; |
| + static PyObject *p3imp_PyExc_KeyError; |
| static PyObject *p3imp_PyExc_KeyboardInterrupt; |
| static PyObject *p3imp_PyExc_TypeError; |
| static PyObject *p3imp_PyExc_ValueError; |
| |
| # define PyExc_AttributeError p3imp_PyExc_AttributeError |
| # define PyExc_IndexError p3imp_PyExc_IndexError |
| + # define PyExc_KeyError p3imp_PyExc_KeyError |
| # define PyExc_KeyboardInterrupt p3imp_PyExc_KeyboardInterrupt |
| # define PyExc_TypeError p3imp_PyExc_TypeError |
| # define PyExc_ValueError p3imp_PyExc_ValueError |
| |
| *** 567,577 **** |
| --- 569,581 ---- |
| PyObject *exdict = PyModule_GetDict(exmod); |
| p3imp_PyExc_AttributeError = PyDict_GetItemString(exdict, "AttributeError"); |
| p3imp_PyExc_IndexError = PyDict_GetItemString(exdict, "IndexError"); |
| + p3imp_PyExc_KeyError = PyDict_GetItemString(exdict, "KeyError"); |
| p3imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt"); |
| p3imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError"); |
| p3imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError"); |
| Py_XINCREF(p3imp_PyExc_AttributeError); |
| Py_XINCREF(p3imp_PyExc_IndexError); |
| + Py_XINCREF(p3imp_PyExc_KeyError); |
| Py_XINCREF(p3imp_PyExc_KeyboardInterrupt); |
| Py_XINCREF(p3imp_PyExc_TypeError); |
| Py_XINCREF(p3imp_PyExc_ValueError); |
| |
| |
| |
| *** 348,359 **** |
| --- 348,361 ---- |
| /* Imported exception objects */ |
| static PyObject *imp_PyExc_AttributeError; |
| static PyObject *imp_PyExc_IndexError; |
| + static PyObject *imp_PyExc_KeyError; |
| static PyObject *imp_PyExc_KeyboardInterrupt; |
| static PyObject *imp_PyExc_TypeError; |
| static PyObject *imp_PyExc_ValueError; |
| |
| # define PyExc_AttributeError imp_PyExc_AttributeError |
| # define PyExc_IndexError imp_PyExc_IndexError |
| + # define PyExc_KeyError imp_PyExc_KeyError |
| # define PyExc_KeyboardInterrupt imp_PyExc_KeyboardInterrupt |
| # define PyExc_TypeError imp_PyExc_TypeError |
| # define PyExc_ValueError imp_PyExc_ValueError |
| |
| *** 579,589 **** |
| --- 581,593 ---- |
| PyObject *exdict = PyModule_GetDict(exmod); |
| imp_PyExc_AttributeError = PyDict_GetItemString(exdict, "AttributeError"); |
| imp_PyExc_IndexError = PyDict_GetItemString(exdict, "IndexError"); |
| + imp_PyExc_KeyError = PyDict_GetItemString(exdict, "KeyError"); |
| imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt"); |
| imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError"); |
| imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError"); |
| Py_XINCREF(imp_PyExc_AttributeError); |
| Py_XINCREF(imp_PyExc_IndexError); |
| + Py_XINCREF(imp_PyExc_KeyError); |
| Py_XINCREF(imp_PyExc_KeyboardInterrupt); |
| Py_XINCREF(imp_PyExc_TypeError); |
| Py_XINCREF(imp_PyExc_ValueError); |
| |
| |
| |
| *** 38,44 **** |
| Vim(python):E725: |
| Vim(python):E117: |
| [0.0, 0.0] |
| ! IndexError |
| TypeError |
| TypeError |
| ValueError |
| --- 38,44 ---- |
| Vim(python):E725: |
| Vim(python):E117: |
| [0.0, 0.0] |
| ! KeyError |
| TypeError |
| TypeError |
| ValueError |
| |
| |
| |
| *** 38,44 **** |
| Vim(py3):E725: |
| Vim(py3):E117: |
| [0.0, 0.0] |
| ! IndexError |
| TypeError |
| TypeError |
| ValueError |
| --- 38,44 ---- |
| Vim(py3):E725: |
| Vim(py3):E117: |
| [0.0, 0.0] |
| ! KeyError |
| TypeError |
| TypeError |
| ValueError |
| |
| |
| |
| *** 730,731 **** |
| --- 730,733 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 907, |
| /**/ |
| |
| -- |
| hundred-and-one symptoms of being an internet addict: |
| 219. Your spouse has his or her lawyer deliver the divorce papers... |
| via e-mail. |
| |
| /// 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 /// |