Karsten Hopp ae61a4
To: vim_dev@googlegroups.com
Karsten Hopp ae61a4
Subject: Patch 7.3.997
Karsten Hopp ae61a4
Fcc: outbox
Karsten Hopp ae61a4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ae61a4
Mime-Version: 1.0
Karsten Hopp ae61a4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ae61a4
Content-Transfer-Encoding: 8bit
Karsten Hopp ae61a4
------------
Karsten Hopp ae61a4
Karsten Hopp ae61a4
Patch 7.3.997
Karsten Hopp ae61a4
Problem:    Vim and Python exceptions are different.
Karsten Hopp ae61a4
Solution:   Make Vim exceptions be Python exceptions. (ZyX)
Karsten Hopp ae61a4
Files:	    src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
Karsten Hopp ae61a4
	    src/testdir/test87.in, src/testdir/test87.ok
Karsten Hopp ae61a4
Karsten Hopp ae61a4
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/if_py_both.h	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/if_py_both.h	2013-05-21 20:35:07.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 272,291 ****
Karsten Hopp ae61a4
  /* Check to see whether a Vim error has been reported, or a keyboard
Karsten Hopp ae61a4
   * interrupt has been detected.
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
! VimErrorCheck(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
      if (got_int)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
Karsten Hopp ae61a4
  	return 1;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
!     else if (did_emsg && !PyErr_Occurred())
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
! 	PyErr_SetNone(VimError);
Karsten Hopp ae61a4
  	return 1;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      return 0;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
--- 272,313 ----
Karsten Hopp ae61a4
  /* Check to see whether a Vim error has been reported, or a keyboard
Karsten Hopp ae61a4
   * interrupt has been detected.
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     static void
Karsten Hopp ae61a4
+ VimTryStart(void)
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     ++trylevel;
Karsten Hopp ae61a4
+ }
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
! VimTryEnd(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
+     --trylevel;
Karsten Hopp ae61a4
      if (got_int)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
Karsten Hopp ae61a4
  	return 1;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
!     else if (!did_throw)
Karsten Hopp ae61a4
! 	return 0;
Karsten Hopp ae61a4
!     else if (PyErr_Occurred())
Karsten Hopp ae61a4
! 	return 1;
Karsten Hopp ae61a4
!     else
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
! 	PyErr_SetVim((char *) current_exception->value);
Karsten Hopp ae61a4
! 	discard_current_exception();
Karsten Hopp ae61a4
  	return 1;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
+ }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     static int
Karsten Hopp ae61a4
+ VimCheckInterrupt(void)
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     if (got_int)
Karsten Hopp ae61a4
+     {
Karsten Hopp ae61a4
+ 	PyErr_SetNone(PyExc_KeyboardInterrupt);
Karsten Hopp ae61a4
+ 	return 1;
Karsten Hopp ae61a4
+     }
Karsten Hopp ae61a4
      return 0;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 306,322 ****
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      do_cmdline_cmd((char_u *)cmd);
Karsten Hopp ae61a4
      update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (VimErrorCheck())
Karsten Hopp ae61a4
  	result = NULL;
Karsten Hopp ae61a4
      else
Karsten Hopp ae61a4
  	result = Py_None;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Py_XINCREF(result);
Karsten Hopp ae61a4
      return result;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
--- 328,346 ----
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      do_cmdline_cmd((char_u *)cmd);
Karsten Hopp ae61a4
      update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (VimTryEnd())
Karsten Hopp ae61a4
  	result = NULL;
Karsten Hopp ae61a4
      else
Karsten Hopp ae61a4
  	result = Py_None;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
      Py_XINCREF(result);
Karsten Hopp ae61a4
      return result;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 449,459 ****
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
      our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      if (our_tv == NULL)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetVim(_("invalid expression"));
Karsten Hopp ae61a4
--- 473,486 ----
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     if (VimTryEnd())
Karsten Hopp ae61a4
+ 	return NULL;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
      if (our_tv == NULL)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetVim(_("invalid expression"));
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 490,500 ****
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
      our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      if (our_tv == NULL)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetVim(_("invalid expression"));
Karsten Hopp ae61a4
--- 517,530 ----
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     if (VimTryEnd())
Karsten Hopp ae61a4
+ 	return NULL;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
      if (our_tv == NULL)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	PyErr_SetVim(_("invalid expression"));
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1324,1335 ****
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      error = func_call(name, &args, selfdict, &rettv);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (error != OK)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	result = NULL;
Karsten Hopp ae61a4
  	PyErr_SetVim(_("failed to run function"));
Karsten Hopp ae61a4
--- 1354,1368 ----
Karsten Hopp ae61a4
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp ae61a4
      Python_Lock_Vim();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      error = func_call(name, &args, selfdict, &rettv);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      Python_Release_Vim();
Karsten Hopp ae61a4
      Py_END_ALLOW_THREADS
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (VimTryEnd())
Karsten Hopp ae61a4
! 	result = NULL;
Karsten Hopp ae61a4
!     else if (error != OK)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	result = NULL;
Karsten Hopp ae61a4
  	PyErr_SetVim(_("failed to run function"));
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1486,1499 ****
Karsten Hopp ae61a4
      win_T	*save_curwin;
Karsten Hopp ae61a4
      tabpage_T	*save_curtab;
Karsten Hopp ae61a4
      buf_T	*save_curbuf;
Karsten Hopp ae61a4
-     int		r = 0;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      switch (opt_type)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	case SREQ_WIN:
Karsten Hopp ae61a4
  	    if (switch_win(&save_curwin, &save_curtab, (win_T *)from,
Karsten Hopp ae61a4
  				     win_find_tabpage((win_T *)from)) == FAIL)
Karsten Hopp ae61a4
  	    {
Karsten Hopp ae61a4
  		PyErr_SetVim("Problem while switching windows.");
Karsten Hopp ae61a4
  		return -1;
Karsten Hopp ae61a4
  	    }
Karsten Hopp ae61a4
--- 1519,1534 ----
Karsten Hopp ae61a4
      win_T	*save_curwin;
Karsten Hopp ae61a4
      tabpage_T	*save_curtab;
Karsten Hopp ae61a4
      buf_T	*save_curbuf;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      switch (opt_type)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	case SREQ_WIN:
Karsten Hopp ae61a4
  	    if (switch_win(&save_curwin, &save_curtab, (win_T *)from,
Karsten Hopp ae61a4
  				     win_find_tabpage((win_T *)from)) == FAIL)
Karsten Hopp ae61a4
  	    {
Karsten Hopp ae61a4
+ 		if (VimTryEnd())
Karsten Hopp ae61a4
+ 		    return -1;
Karsten Hopp ae61a4
  		PyErr_SetVim("Problem while switching windows.");
Karsten Hopp ae61a4
  		return -1;
Karsten Hopp ae61a4
  	    }
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1509,1515 ****
Karsten Hopp ae61a4
  	    set_option_value(key, numval, stringval, opt_flags);
Karsten Hopp ae61a4
  	    break;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
!     return r;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
--- 1544,1550 ----
Karsten Hopp ae61a4
  	    set_option_value(key, numval, stringval, opt_flags);
Karsten Hopp ae61a4
  	    break;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
!     return VimTryEnd();
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1961,1967 ****
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	/* Check for keyboard interrupts */
Karsten Hopp ae61a4
! 	if (VimErrorCheck())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	self->win->w_cursor.lnum = lnum;
Karsten Hopp ae61a4
--- 1996,2002 ----
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	/* Check for keyboard interrupts */
Karsten Hopp ae61a4
! 	if (VimCheckInterrupt())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	self->win->w_cursor.lnum = lnum;
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1988,1998 ****
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  	savewin = curwin;
Karsten Hopp ae61a4
  	curwin = self->win;
Karsten Hopp ae61a4
  	win_setheight(height);
Karsten Hopp ae61a4
  	curwin = savewin;
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! 	/* Check for keyboard interrupts */
Karsten Hopp ae61a4
! 	if (VimErrorCheck())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	return 0;
Karsten Hopp ae61a4
--- 2023,2033 ----
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  	savewin = curwin;
Karsten Hopp ae61a4
  	curwin = self->win;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	win_setheight(height);
Karsten Hopp ae61a4
  	curwin = savewin;
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	return 0;
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2011,2021 ****
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  	savewin = curwin;
Karsten Hopp ae61a4
  	curwin = self->win;
Karsten Hopp ae61a4
  	win_setwidth(width);
Karsten Hopp ae61a4
  	curwin = savewin;
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! 	/* Check for keyboard interrupts */
Karsten Hopp ae61a4
! 	if (VimErrorCheck())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	return 0;
Karsten Hopp ae61a4
--- 2046,2056 ----
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  	savewin = curwin;
Karsten Hopp ae61a4
  	curwin = self->win;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	win_setwidth(width);
Karsten Hopp ae61a4
  	curwin = savewin;
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	return 0;
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2304,2309 ****
Karsten Hopp ae61a4
--- 2339,2346 ----
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
  	switch_buffer(&savebuf, buf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
  	if (u_savedel((linenr_T)n, 1L) == FAIL)
Karsten Hopp ae61a4
  	    PyErr_SetVim(_("cannot save undo information"));
Karsten Hopp ae61a4
  	else if (ml_delete((linenr_T)n, FALSE) == FAIL)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2317,2323 ****
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2354,2360 ----
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2333,2338 ****
Karsten Hopp ae61a4
--- 2370,2377 ----
Karsten Hopp ae61a4
  	if (save == NULL)
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
  	/* We do not need to free "save" if ml_replace() consumes it. */
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
  	switch_buffer(&savebuf, buf);
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2356,2362 ****
Karsten Hopp ae61a4
  	if (buf == savebuf)
Karsten Hopp ae61a4
  	    check_cursor_col();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2395,2401 ----
Karsten Hopp ae61a4
  	if (buf == savebuf)
Karsten Hopp ae61a4
  	    check_cursor_col();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2395,2400 ****
Karsten Hopp ae61a4
--- 2434,2440 ----
Karsten Hopp ae61a4
  	buf_T	*savebuf;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	switch_buffer(&savebuf, buf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (u_savedel((linenr_T)lo, (long)n) == FAIL)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2416,2422 ****
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2456,2462 ----
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2459,2464 ****
Karsten Hopp ae61a4
--- 2499,2505 ----
Karsten Hopp ae61a4
  	    }
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	// START of region without "return".  Must call restore_buffer()!
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2545,2551 ****
Karsten Hopp ae61a4
  	// END of region without "return".
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2586,2592 ----
Karsten Hopp ae61a4
  	// END of region without "return".
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2583,2588 ****
Karsten Hopp ae61a4
--- 2624,2630 ----
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	switch_buffer(&savebuf, buf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2596,2602 ****
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  	update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2638,2644 ----
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  	update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2633,2638 ****
Karsten Hopp ae61a4
--- 2675,2681 ----
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	PyErr_Clear();
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	switch_buffer(&savebuf, buf);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2666,2672 ****
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  	update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PyErr_Occurred() || VimErrorCheck())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
--- 2709,2715 ----
Karsten Hopp ae61a4
  	restore_buffer(savebuf);
Karsten Hopp ae61a4
  	update_screen(VALID);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (VimTryEnd())
Karsten Hopp ae61a4
  	    return FAIL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (len_change)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 2896,2902 ****
Karsten Hopp ae61a4
      static void
Karsten Hopp ae61a4
  RangeDestructor(RangeObject *self)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
!     Py_DECREF(self->buf);
Karsten Hopp ae61a4
      DESTRUCTOR_FINISH(self);
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
--- 2939,2945 ----
Karsten Hopp ae61a4
      static void
Karsten Hopp ae61a4
  RangeDestructor(RangeObject *self)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
!     Py_XDECREF(self->buf);
Karsten Hopp ae61a4
      DESTRUCTOR_FINISH(self);
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 3078,3086 ****
Karsten Hopp ae61a4
--- 3121,3132 ----
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
      mark = *pmark;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+     VimTryStart();
Karsten Hopp ae61a4
      switch_buffer(&savebuf, self->buf);
Karsten Hopp ae61a4
      posp = getmark(mark, FALSE);
Karsten Hopp ae61a4
      restore_buffer(savebuf);
Karsten Hopp ae61a4
+     if (VimTryEnd())
Karsten Hopp ae61a4
+ 	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      if (posp == NULL)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 3088,3097 ****
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
-     /* Check for keyboard interrupt */
Karsten Hopp ae61a4
-     if (VimErrorCheck())
Karsten Hopp ae61a4
- 	return NULL;
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
      if (posp->lnum <= 0)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
  	/* Or raise an error? */
Karsten Hopp ae61a4
--- 3134,3139 ----
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 3330,3342 ****
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	count = ((BufferObject *)(value))->buf->b_fnum;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
  	    PyErr_SetVim(_("failed to switch to given buffer"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return 0;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else if (strcmp(name, "window") == 0)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
--- 3372,3387 ----
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	count = ((BufferObject *)(value))->buf->b_fnum;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
+ 	    if (VimTryEnd())
Karsten Hopp ae61a4
+ 		return -1;
Karsten Hopp ae61a4
  	    PyErr_SetVim(_("failed to switch to given buffer"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return VimTryEnd();
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else if (strcmp(name, "window") == 0)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 3359,3373 ****
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	win_goto(((WindowObject *)(value))->win);
Karsten Hopp ae61a4
  	if (((WindowObject *)(value))->win != curwin)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
  	    PyErr_SetString(PyExc_RuntimeError,
Karsten Hopp ae61a4
  		    _("did not switch to the specified window"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return 0;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else if (strcmp(name, "tabpage") == 0)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
--- 3404,3421 ----
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	win_goto(((WindowObject *)(value))->win);
Karsten Hopp ae61a4
  	if (((WindowObject *)(value))->win != curwin)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
+ 	    if (VimTryEnd())
Karsten Hopp ae61a4
+ 		return -1;
Karsten Hopp ae61a4
  	    PyErr_SetString(PyExc_RuntimeError,
Karsten Hopp ae61a4
  		    _("did not switch to the specified window"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return VimTryEnd();
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else if (strcmp(name, "tabpage") == 0)
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 3380,3394 ****
Karsten Hopp ae61a4
  	if (CheckTabPage((TabPageObject *)(value)))
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE);
Karsten Hopp ae61a4
  	if (((TabPageObject *)(value))->tab != curtab)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
  	    PyErr_SetString(PyExc_RuntimeError,
Karsten Hopp ae61a4
  		    _("did not switch to the specified tab page"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return 0;
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
--- 3428,3445 ----
Karsten Hopp ae61a4
  	if (CheckTabPage((TabPageObject *)(value)))
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
+ 	VimTryStart();
Karsten Hopp ae61a4
  	goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE);
Karsten Hopp ae61a4
  	if (((TabPageObject *)(value))->tab != curtab)
Karsten Hopp ae61a4
  	{
Karsten Hopp ae61a4
+ 	    if (VimTryEnd())
Karsten Hopp ae61a4
+ 		return -1;
Karsten Hopp ae61a4
  	    PyErr_SetString(PyExc_RuntimeError,
Karsten Hopp ae61a4
  		    _("did not switch to the specified tab page"));
Karsten Hopp ae61a4
  	    return -1;
Karsten Hopp ae61a4
  	}
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	return VimTryEnd();
Karsten Hopp ae61a4
      }
Karsten Hopp ae61a4
      else
Karsten Hopp ae61a4
      {
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/testdir/test86.in	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/testdir/test86.in	2013-05-21 20:34:32.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 380,399 ****
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          exec(s, g, l)
Karsten Hopp ae61a4
      except:
Karsten Hopp ae61a4
!         vim.command('throw ' + repr(sys.exc_type.__name__))
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  def ev(s, g=globals(), l=locals()):
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          return eval(s, g, l)
Karsten Hopp ae61a4
      except:
Karsten Hopp ae61a4
!         vim.command('throw ' + repr(sys.exc_type.__name__))
Karsten Hopp ae61a4
          return 0
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
  :function E(s)
Karsten Hopp ae61a4
  :   python e(vim.eval('a:s'))
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :function Ev(s)
Karsten Hopp ae61a4
! :   return pyeval('ev(vim.eval("a:s"))')
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :py gopts1=vim.options
Karsten Hopp ae61a4
  :py wopts1=vim.windows[2].options
Karsten Hopp ae61a4
--- 380,403 ----
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          exec(s, g, l)
Karsten Hopp ae61a4
      except:
Karsten Hopp ae61a4
!         vim.command('return ' + repr(sys.exc_type.__name__))
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  def ev(s, g=globals(), l=locals()):
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          return eval(s, g, l)
Karsten Hopp ae61a4
      except:
Karsten Hopp ae61a4
!         vim.command('let exc=' + repr(sys.exc_type.__name__))
Karsten Hopp ae61a4
          return 0
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
  :function E(s)
Karsten Hopp ae61a4
  :   python e(vim.eval('a:s'))
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :function Ev(s)
Karsten Hopp ae61a4
! :   let r=pyeval('ev(vim.eval("a:s"))')
Karsten Hopp ae61a4
! :   if exists('exc')
Karsten Hopp ae61a4
! :       throw exc
Karsten Hopp ae61a4
! :   endif
Karsten Hopp ae61a4
! :   return r
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :py gopts1=vim.options
Karsten Hopp ae61a4
  :py wopts1=vim.windows[2].options
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 437,463 ****
Karsten Hopp ae61a4
  :       catch
Karsten Hopp ae61a4
  :           put ='  p/'.v.'! '.v:exception
Karsten Hopp ae61a4
  :       endtry
Karsten Hopp ae61a4
! :       try
Karsten Hopp ae61a4
! :           call E(v.'["'.oname.'"]=invval')
Karsten Hopp ae61a4
! :       catch
Karsten Hopp ae61a4
! :           put ='  inv: '.string(invval).'! '.v:exception
Karsten Hopp ae61a4
! :       endtry
Karsten Hopp ae61a4
  :       for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3'])
Karsten Hopp ae61a4
  :           let val=substitute(vv, '^.opts', 'oval', '')
Karsten Hopp ae61a4
! :           try
Karsten Hopp ae61a4
! :               call E(vv.'["'.oname.'"]='.val)
Karsten Hopp ae61a4
! :           catch
Karsten Hopp ae61a4
! :               put ='  '.vv.'! '.v:exception
Karsten Hopp ae61a4
! :           endtry
Karsten Hopp ae61a4
  :       endfor
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :   for v in ['wopts3', 'bopts3']
Karsten Hopp ae61a4
! :       try
Karsten Hopp ae61a4
! :           call E('del '.v.'["'.oname.'"]')
Karsten Hopp ae61a4
! :       catch
Karsten Hopp ae61a4
! :           put ='  del '.v.'! '.v:exception
Karsten Hopp ae61a4
! :       endtry
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :endfor
Karsten Hopp ae61a4
--- 441,464 ----
Karsten Hopp ae61a4
  :       catch
Karsten Hopp ae61a4
  :           put ='  p/'.v.'! '.v:exception
Karsten Hopp ae61a4
  :       endtry
Karsten Hopp ae61a4
! :       let r=E(v.'['''.oname.''']=invval')
Karsten Hopp ae61a4
! :       if r isnot 0
Karsten Hopp ae61a4
! :           put ='  inv: '.string(invval).'! '.r
Karsten Hopp ae61a4
! :       endif
Karsten Hopp ae61a4
  :       for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3'])
Karsten Hopp ae61a4
  :           let val=substitute(vv, '^.opts', 'oval', '')
Karsten Hopp ae61a4
! :           let r=E(vv.'['''.oname.''']='.val)
Karsten Hopp ae61a4
! :           if r isnot 0
Karsten Hopp ae61a4
! :               put ='  '.vv.'! '.r
Karsten Hopp ae61a4
! :           endif
Karsten Hopp ae61a4
  :       endfor
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :   for v in ['wopts3', 'bopts3']
Karsten Hopp ae61a4
! :       let r=E('del '.v.'["'.oname.'"]')
Karsten Hopp ae61a4
! :       if r isnot 0
Karsten Hopp ae61a4
! :           put ='  del '.v.'! '.r
Karsten Hopp ae61a4
! :       endif
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :endfor
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 651,656 ****
Karsten Hopp ae61a4
--- 652,676 ----
Karsten Hopp ae61a4
  ):
Karsten Hopp ae61a4
      cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
+ :"
Karsten Hopp ae61a4
+ :" Test exceptions
Karsten Hopp ae61a4
+ :fun Exe(e)
Karsten Hopp ae61a4
+ :   execute a:e
Karsten Hopp ae61a4
+ :endfun
Karsten Hopp ae61a4
+ py << EOF
Karsten Hopp ae61a4
+ def ee(expr, g=globals(), l=locals()):
Karsten Hopp ae61a4
+     try:
Karsten Hopp ae61a4
+         exec(expr, g, l)
Karsten Hopp ae61a4
+     except:
Karsten Hopp ae61a4
+         cb.append(repr(sys.exc_info()[:2]))
Karsten Hopp ae61a4
+ Exe = vim.bindeval('function("Exe")')
Karsten Hopp ae61a4
+ ee('vim.command("throw \'abc\'")')
Karsten Hopp ae61a4
+ ee('Exe("throw \'def\'")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")')
Karsten Hopp ae61a4
+ ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")')
Karsten Hopp ae61a4
+ EOF
Karsten Hopp ae61a4
  :endfun
Karsten Hopp ae61a4
  :"
Karsten Hopp ae61a4
  :call Test()
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/testdir/test86.ok	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/testdir/test86.ok	2013-05-21 20:38:29.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 333,339 ****
Karsten Hopp ae61a4
  Current tab pages:
Karsten Hopp ae61a4
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
!     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (970, 0)
Karsten Hopp ae61a4
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
Karsten Hopp ae61a4
--- 333,339 ----
Karsten Hopp ae61a4
  Current tab pages:
Karsten Hopp ae61a4
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
!     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (990, 0)
Karsten Hopp ae61a4
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 368,370 ****
Karsten Hopp ae61a4
--- 368,376 ----
Karsten Hopp ae61a4
  vim.current.range:Range:True
Karsten Hopp ae61a4
  vim.current.window:Window:True
Karsten Hopp ae61a4
  vim.current.tabpage:TabPage:True
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('abc',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('def',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('ghi',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim(echoerr):jkl',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/testdir/test87.in	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/testdir/test87.in	2013-05-21 20:34:32.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 367,386 ****
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          exec(s, g, l)
Karsten Hopp ae61a4
      except Exception as e:
Karsten Hopp ae61a4
!         vim.command('throw ' + repr(e.__class__.__name__))
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  def ev(s, g=globals(), l=locals()):
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          return eval(s, g, l)
Karsten Hopp ae61a4
      except Exception as e:
Karsten Hopp ae61a4
!         vim.command('throw ' + repr(e.__class__.__name__))
Karsten Hopp ae61a4
          return 0
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
  :function E(s)
Karsten Hopp ae61a4
  :   python3 e(vim.eval('a:s'))
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :function Ev(s)
Karsten Hopp ae61a4
! :   return py3eval('ev(vim.eval("a:s"))')
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :py3 gopts1=vim.options
Karsten Hopp ae61a4
  :py3 wopts1=vim.windows[2].options
Karsten Hopp ae61a4
--- 367,390 ----
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          exec(s, g, l)
Karsten Hopp ae61a4
      except Exception as e:
Karsten Hopp ae61a4
!         vim.command('return ' + repr(e.__class__.__name__))
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  def ev(s, g=globals(), l=locals()):
Karsten Hopp ae61a4
      try:
Karsten Hopp ae61a4
          return eval(s, g, l)
Karsten Hopp ae61a4
      except Exception as e:
Karsten Hopp ae61a4
!         vim.command('let exc=' + repr(e.__class__.__name__))
Karsten Hopp ae61a4
          return 0
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
  :function E(s)
Karsten Hopp ae61a4
  :   python3 e(vim.eval('a:s'))
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :function Ev(s)
Karsten Hopp ae61a4
! :   let r=py3eval('ev(vim.eval("a:s"))')
Karsten Hopp ae61a4
! :   if exists('exc')
Karsten Hopp ae61a4
! :       throw exc
Karsten Hopp ae61a4
! :   endif
Karsten Hopp ae61a4
! :   return r
Karsten Hopp ae61a4
  :endfunction
Karsten Hopp ae61a4
  :py3 gopts1=vim.options
Karsten Hopp ae61a4
  :py3 wopts1=vim.windows[2].options
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 424,450 ****
Karsten Hopp ae61a4
  :       catch
Karsten Hopp ae61a4
  :           put ='  p/'.v.'! '.v:exception
Karsten Hopp ae61a4
  :       endtry
Karsten Hopp ae61a4
! :       try
Karsten Hopp ae61a4
! :           call E(v.'["'.oname.'"]=invval')
Karsten Hopp ae61a4
! :       catch
Karsten Hopp ae61a4
! :           put ='  inv: '.string(invval).'! '.v:exception
Karsten Hopp ae61a4
! :       endtry
Karsten Hopp ae61a4
  :       for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3'])
Karsten Hopp ae61a4
  :           let val=substitute(vv, '^.opts', 'oval', '')
Karsten Hopp ae61a4
! :           try
Karsten Hopp ae61a4
! :               call E(vv.'["'.oname.'"]='.val)
Karsten Hopp ae61a4
! :           catch
Karsten Hopp ae61a4
! :               put ='  '.vv.'! '.v:exception
Karsten Hopp ae61a4
! :           endtry
Karsten Hopp ae61a4
  :       endfor
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :   for v in ['wopts3', 'bopts3']
Karsten Hopp ae61a4
! :       try
Karsten Hopp ae61a4
! :           call E('del '.v.'["'.oname.'"]')
Karsten Hopp ae61a4
! :       catch
Karsten Hopp ae61a4
! :           put ='  del '.v.'! '.v:exception
Karsten Hopp ae61a4
! :       endtry
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :endfor
Karsten Hopp ae61a4
--- 428,451 ----
Karsten Hopp ae61a4
  :       catch
Karsten Hopp ae61a4
  :           put ='  p/'.v.'! '.v:exception
Karsten Hopp ae61a4
  :       endtry
Karsten Hopp ae61a4
! :       let r=E(v.'['''.oname.''']=invval')
Karsten Hopp ae61a4
! :       if r isnot 0
Karsten Hopp ae61a4
! :           put ='  inv: '.string(invval).'! '.r
Karsten Hopp ae61a4
! :       endif
Karsten Hopp ae61a4
  :       for vv in (v is# 'gopts1' ? [v] : [v, v[:-2].'2', v[:-2].'3'])
Karsten Hopp ae61a4
  :           let val=substitute(vv, '^.opts', 'oval', '')
Karsten Hopp ae61a4
! :           let r=E(vv.'['''.oname.''']='.val)
Karsten Hopp ae61a4
! :           if r isnot 0
Karsten Hopp ae61a4
! :               put ='  '.vv.'! '.r
Karsten Hopp ae61a4
! :           endif
Karsten Hopp ae61a4
  :       endfor
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :   for v in ['wopts3', 'bopts3']
Karsten Hopp ae61a4
! :       let r=E('del '.v.'["'.oname.'"]')
Karsten Hopp ae61a4
! :       if r isnot 0
Karsten Hopp ae61a4
! :           put ='  del '.v.'! '.r
Karsten Hopp ae61a4
! :       endif
Karsten Hopp ae61a4
  :   endfor
Karsten Hopp ae61a4
  :   call RecVars(oname)
Karsten Hopp ae61a4
  :endfor
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 638,643 ****
Karsten Hopp ae61a4
--- 639,663 ----
Karsten Hopp ae61a4
  ):
Karsten Hopp ae61a4
      cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
Karsten Hopp ae61a4
  EOF
Karsten Hopp ae61a4
+ :"
Karsten Hopp ae61a4
+ :" Test exceptions
Karsten Hopp ae61a4
+ :fun Exe(e)
Karsten Hopp ae61a4
+ :   execute a:e
Karsten Hopp ae61a4
+ :endfun
Karsten Hopp ae61a4
+ py3 << EOF
Karsten Hopp ae61a4
+ def ee(expr, g=globals(), l=locals()):
Karsten Hopp ae61a4
+     try:
Karsten Hopp ae61a4
+         exec(expr, g, l)
Karsten Hopp ae61a4
+     except Exception as e:
Karsten Hopp ae61a4
+         cb.append(repr((e.__class__, e)))
Karsten Hopp ae61a4
+ Exe = vim.bindeval('function("Exe")')
Karsten Hopp ae61a4
+ ee('vim.command("throw \'abc\'")')
Karsten Hopp ae61a4
+ ee('Exe("throw \'def\'")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")')
Karsten Hopp ae61a4
+ ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")')
Karsten Hopp ae61a4
+ ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")')
Karsten Hopp ae61a4
+ EOF
Karsten Hopp ae61a4
  :endfun
Karsten Hopp ae61a4
  :"
Karsten Hopp ae61a4
  :call Test()
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/testdir/test87.ok	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/testdir/test87.ok	2013-05-21 20:38:46.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 322,328 ****
Karsten Hopp ae61a4
  Current tab pages:
Karsten Hopp ae61a4
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
!     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (946, 0)
Karsten Hopp ae61a4
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
Karsten Hopp ae61a4
--- 322,328 ----
Karsten Hopp ae61a4
  Current tab pages:
Karsten Hopp ae61a4
    <tabpage 0>(1): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
!     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (966, 0)
Karsten Hopp ae61a4
    <tabpage 1>(2): 1 windows, current is <window object (unknown)>
Karsten Hopp ae61a4
    Windows:
Karsten Hopp ae61a4
      <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 357,359 ****
Karsten Hopp ae61a4
--- 357,365 ----
Karsten Hopp ae61a4
  vim.current.range:Range:True
Karsten Hopp ae61a4
  vim.current.window:Window:True
Karsten Hopp ae61a4
  vim.current.tabpage:TabPage:True
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('abc',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('def',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('ghi',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim(echoerr):jkl',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp ae61a4
+ (<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp ae61a4
*** ../vim-7.3.996/src/version.c	2013-05-21 19:49:58.000000000 +0200
Karsten Hopp ae61a4
--- src/version.c	2013-05-21 20:32:46.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 730,731 ****
Karsten Hopp ae61a4
--- 730,733 ----
Karsten Hopp ae61a4
  {   /* Add new patch number below this line */
Karsten Hopp ae61a4
+ /**/
Karsten Hopp ae61a4
+     997,
Karsten Hopp ae61a4
  /**/
Karsten Hopp ae61a4
Karsten Hopp ae61a4
-- 
Karsten Hopp ae61a4
ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot.
Karsten Hopp ae61a4
        King of all Britons, defeator of the Saxons, sovereign of all England!
Karsten Hopp ae61a4
   [Pause]
Karsten Hopp ae61a4
SOLDIER: Get away!
Karsten Hopp ae61a4
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp ae61a4
Karsten Hopp ae61a4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ae61a4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ae61a4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ae61a4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///