Karsten Hopp c3bbd5
To: vim_dev@googlegroups.com
Karsten Hopp c3bbd5
Subject: Patch 7.3.907
Karsten Hopp c3bbd5
Fcc: outbox
Karsten Hopp c3bbd5
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp c3bbd5
Mime-Version: 1.0
Karsten Hopp c3bbd5
Content-Type: text/plain; charset=UTF-8
Karsten Hopp c3bbd5
Content-Transfer-Encoding: 8bit
Karsten Hopp c3bbd5
------------
Karsten Hopp c3bbd5
Karsten Hopp c3bbd5
Patch 7.3.907
Karsten Hopp c3bbd5
Problem:    Python uses IndexError when a dict key is not found.
Karsten Hopp c3bbd5
Solution:   Use KeyError instead. (ZyX)
Karsten Hopp c3bbd5
Files:	    src/if_py_both.h, src/if_python3.c, src/if_python.c,
Karsten Hopp c3bbd5
	    src/testdir/test86.ok, src/testdir/test87.ok
Karsten Hopp c3bbd5
Karsten Hopp c3bbd5
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/if_py_both.h	2013-04-05 19:32:30.000000000 +0200
Karsten Hopp c3bbd5
--- src/if_py_both.h	2013-04-24 13:00:01.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 861,867 ****
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
      if (di == NULL)
Karsten Hopp c3bbd5
      {
Karsten Hopp c3bbd5
! 	PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
Karsten Hopp c3bbd5
  	return NULL;
Karsten Hopp c3bbd5
      }
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
--- 861,867 ----
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
      if (di == NULL)
Karsten Hopp c3bbd5
      {
Karsten Hopp c3bbd5
! 	PyErr_SetString(PyExc_KeyError, _("no such key in dictionary"));
Karsten Hopp c3bbd5
  	return NULL;
Karsten Hopp c3bbd5
      }
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/if_python3.c	2013-02-20 16:09:35.000000000 +0100
Karsten Hopp c3bbd5
--- src/if_python3.c	2013-04-24 13:00:01.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 327,338 ****
Karsten Hopp c3bbd5
--- 327,340 ----
Karsten Hopp c3bbd5
  /* Imported exception objects */
Karsten Hopp c3bbd5
  static PyObject *p3imp_PyExc_AttributeError;
Karsten Hopp c3bbd5
  static PyObject *p3imp_PyExc_IndexError;
Karsten Hopp c3bbd5
+ static PyObject *p3imp_PyExc_KeyError;
Karsten Hopp c3bbd5
  static PyObject *p3imp_PyExc_KeyboardInterrupt;
Karsten Hopp c3bbd5
  static PyObject *p3imp_PyExc_TypeError;
Karsten Hopp c3bbd5
  static PyObject *p3imp_PyExc_ValueError;
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
  # define PyExc_AttributeError p3imp_PyExc_AttributeError
Karsten Hopp c3bbd5
  # define PyExc_IndexError p3imp_PyExc_IndexError
Karsten Hopp c3bbd5
+ # define PyExc_KeyError p3imp_PyExc_KeyError
Karsten Hopp c3bbd5
  # define PyExc_KeyboardInterrupt p3imp_PyExc_KeyboardInterrupt
Karsten Hopp c3bbd5
  # define PyExc_TypeError p3imp_PyExc_TypeError
Karsten Hopp c3bbd5
  # define PyExc_ValueError p3imp_PyExc_ValueError
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 567,577 ****
Karsten Hopp c3bbd5
--- 569,581 ----
Karsten Hopp c3bbd5
      PyObject *exdict = PyModule_GetDict(exmod);
Karsten Hopp c3bbd5
      p3imp_PyExc_AttributeError = PyDict_GetItemString(exdict, "AttributeError");
Karsten Hopp c3bbd5
      p3imp_PyExc_IndexError = PyDict_GetItemString(exdict, "IndexError");
Karsten Hopp c3bbd5
+     p3imp_PyExc_KeyError = PyDict_GetItemString(exdict, "KeyError");
Karsten Hopp c3bbd5
      p3imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt");
Karsten Hopp c3bbd5
      p3imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
Karsten Hopp c3bbd5
      p3imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
Karsten Hopp c3bbd5
      Py_XINCREF(p3imp_PyExc_AttributeError);
Karsten Hopp c3bbd5
      Py_XINCREF(p3imp_PyExc_IndexError);
Karsten Hopp c3bbd5
+     Py_XINCREF(p3imp_PyExc_KeyError);
Karsten Hopp c3bbd5
      Py_XINCREF(p3imp_PyExc_KeyboardInterrupt);
Karsten Hopp c3bbd5
      Py_XINCREF(p3imp_PyExc_TypeError);
Karsten Hopp c3bbd5
      Py_XINCREF(p3imp_PyExc_ValueError);
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/if_python.c	2013-02-20 16:09:35.000000000 +0100
Karsten Hopp c3bbd5
--- src/if_python.c	2013-04-24 13:00:01.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 348,359 ****
Karsten Hopp c3bbd5
--- 348,361 ----
Karsten Hopp c3bbd5
  /* Imported exception objects */
Karsten Hopp c3bbd5
  static PyObject *imp_PyExc_AttributeError;
Karsten Hopp c3bbd5
  static PyObject *imp_PyExc_IndexError;
Karsten Hopp c3bbd5
+ static PyObject *imp_PyExc_KeyError;
Karsten Hopp c3bbd5
  static PyObject *imp_PyExc_KeyboardInterrupt;
Karsten Hopp c3bbd5
  static PyObject *imp_PyExc_TypeError;
Karsten Hopp c3bbd5
  static PyObject *imp_PyExc_ValueError;
Karsten Hopp c3bbd5
  
Karsten Hopp c3bbd5
  # define PyExc_AttributeError imp_PyExc_AttributeError
Karsten Hopp c3bbd5
  # define PyExc_IndexError imp_PyExc_IndexError
Karsten Hopp c3bbd5
+ # define PyExc_KeyError imp_PyExc_KeyError
Karsten Hopp c3bbd5
  # define PyExc_KeyboardInterrupt imp_PyExc_KeyboardInterrupt
Karsten Hopp c3bbd5
  # define PyExc_TypeError imp_PyExc_TypeError
Karsten Hopp c3bbd5
  # define PyExc_ValueError imp_PyExc_ValueError
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 579,589 ****
Karsten Hopp c3bbd5
--- 581,593 ----
Karsten Hopp c3bbd5
      PyObject *exdict = PyModule_GetDict(exmod);
Karsten Hopp c3bbd5
      imp_PyExc_AttributeError = PyDict_GetItemString(exdict, "AttributeError");
Karsten Hopp c3bbd5
      imp_PyExc_IndexError = PyDict_GetItemString(exdict, "IndexError");
Karsten Hopp c3bbd5
+     imp_PyExc_KeyError = PyDict_GetItemString(exdict, "KeyError");
Karsten Hopp c3bbd5
      imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt");
Karsten Hopp c3bbd5
      imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
Karsten Hopp c3bbd5
      imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
Karsten Hopp c3bbd5
      Py_XINCREF(imp_PyExc_AttributeError);
Karsten Hopp c3bbd5
      Py_XINCREF(imp_PyExc_IndexError);
Karsten Hopp c3bbd5
+     Py_XINCREF(imp_PyExc_KeyError);
Karsten Hopp c3bbd5
      Py_XINCREF(imp_PyExc_KeyboardInterrupt);
Karsten Hopp c3bbd5
      Py_XINCREF(imp_PyExc_TypeError);
Karsten Hopp c3bbd5
      Py_XINCREF(imp_PyExc_ValueError);
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/testdir/test86.ok	2013-04-05 19:32:30.000000000 +0200
Karsten Hopp c3bbd5
--- src/testdir/test86.ok	2013-04-24 13:00:01.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 38,44 ****
Karsten Hopp c3bbd5
  Vim(python):E725:
Karsten Hopp c3bbd5
  Vim(python):E117:
Karsten Hopp c3bbd5
  [0.0, 0.0]
Karsten Hopp c3bbd5
! IndexError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  ValueError
Karsten Hopp c3bbd5
--- 38,44 ----
Karsten Hopp c3bbd5
  Vim(python):E725:
Karsten Hopp c3bbd5
  Vim(python):E117:
Karsten Hopp c3bbd5
  [0.0, 0.0]
Karsten Hopp c3bbd5
! KeyError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  ValueError
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/testdir/test87.ok	2013-02-20 16:54:24.000000000 +0100
Karsten Hopp c3bbd5
--- src/testdir/test87.ok	2013-04-24 13:00:01.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 38,44 ****
Karsten Hopp c3bbd5
  Vim(py3):E725:
Karsten Hopp c3bbd5
  Vim(py3):E117:
Karsten Hopp c3bbd5
  [0.0, 0.0]
Karsten Hopp c3bbd5
! IndexError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  ValueError
Karsten Hopp c3bbd5
--- 38,44 ----
Karsten Hopp c3bbd5
  Vim(py3):E725:
Karsten Hopp c3bbd5
  Vim(py3):E117:
Karsten Hopp c3bbd5
  [0.0, 0.0]
Karsten Hopp c3bbd5
! KeyError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  TypeError
Karsten Hopp c3bbd5
  ValueError
Karsten Hopp c3bbd5
*** ../vim-7.3.906/src/version.c	2013-04-24 12:56:13.000000000 +0200
Karsten Hopp c3bbd5
--- src/version.c	2013-04-24 13:00:13.000000000 +0200
Karsten Hopp c3bbd5
***************
Karsten Hopp c3bbd5
*** 730,731 ****
Karsten Hopp c3bbd5
--- 730,733 ----
Karsten Hopp c3bbd5
  {   /* Add new patch number below this line */
Karsten Hopp c3bbd5
+ /**/
Karsten Hopp c3bbd5
+     907,
Karsten Hopp c3bbd5
  /**/
Karsten Hopp c3bbd5
Karsten Hopp c3bbd5
-- 
Karsten Hopp c3bbd5
hundred-and-one symptoms of being an internet addict:
Karsten Hopp c3bbd5
219. Your spouse has his or her lawyer deliver the divorce papers...
Karsten Hopp c3bbd5
     via e-mail.
Karsten Hopp c3bbd5
Karsten Hopp c3bbd5
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp c3bbd5
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp c3bbd5
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp c3bbd5
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///