Blame SOURCES/7.4.107

d6ba96
To: vim_dev@googlegroups.com
d6ba96
Subject: Patch 7.4.107
d6ba96
Fcc: outbox
d6ba96
From: Bram Moolenaar <Bram@moolenaar.net>
d6ba96
Mime-Version: 1.0
d6ba96
Content-Type: text/plain; charset=UTF-8
d6ba96
Content-Transfer-Encoding: 8bit
d6ba96
------------
d6ba96
d6ba96
Patch 7.4.107
d6ba96
Problem:    Python: When vim.eval() encounters a Vim error, a try/catch in the
d6ba96
	    Python code doesn't catch it. (Yggdroot Chen)
d6ba96
Solution:   Throw exceptions on errors in vim.eval(). (ZyX)
d6ba96
Files:	    src/ex_eval.c, src/if_py_both.h, src/proto/ex_eval.pro,
d6ba96
	    src/testdir/test86.in, src/testdir/test86.ok,
d6ba96
	    src/testdir/test87.in, src/testdir/test87.ok
d6ba96
d6ba96
d6ba96
*** ../vim-7.4.106/src/ex_eval.c	2013-06-08 15:50:28.000000000 +0200
d6ba96
--- src/ex_eval.c	2013-11-28 16:59:09.000000000 +0100
d6ba96
***************
d6ba96
*** 321,326 ****
d6ba96
--- 321,337 ----
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
+  * Free global "*msg_list" and the messages it contains, then set "*msg_list"
d6ba96
+  * to NULL.
d6ba96
+  */
d6ba96
+     void
d6ba96
+ free_global_msglist()
d6ba96
+ {
d6ba96
+     free_msglist(*msg_list);
d6ba96
+     *msg_list = NULL;
d6ba96
+ }
d6ba96
+ 
d6ba96
+ /*
d6ba96
   * Throw the message specified in the call to cause_errthrow() above as an
d6ba96
   * error exception.  If cstack is NULL, postpone the throw until do_cmdline()
d6ba96
   * has returned (see do_one_cmd()).
d6ba96
***************
d6ba96
*** 410,475 ****
d6ba96
      return TRUE;
d6ba96
  }
d6ba96
  
d6ba96
- 
d6ba96
  /*
d6ba96
!  * Throw a new exception.  Return FAIL when out of memory or it was tried to
d6ba96
!  * throw an illegal user exception.  "value" is the exception string for a user
d6ba96
!  * or interrupt exception, or points to a message list in case of an error
d6ba96
!  * exception.
d6ba96
   */
d6ba96
!     static int
d6ba96
! throw_exception(value, type, cmdname)
d6ba96
      void	*value;
d6ba96
      int		type;
d6ba96
      char_u	*cmdname;
d6ba96
  {
d6ba96
!     except_T	*excp;
d6ba96
!     char_u	*p, *mesg, *val;
d6ba96
      int		cmdlen;
d6ba96
! 
d6ba96
!     /*
d6ba96
!      * Disallow faking Interrupt or error exceptions as user exceptions.  They
d6ba96
!      * would be treated differently from real interrupt or error exceptions when
d6ba96
!      * no active try block is found, see do_cmdline().
d6ba96
!      */
d6ba96
!     if (type == ET_USER)
d6ba96
!     {
d6ba96
! 	if (STRNCMP((char_u *)value, "Vim", 3) == 0 &&
d6ba96
! 		(((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':' ||
d6ba96
! 		 ((char_u *)value)[3] == '('))
d6ba96
! 	{
d6ba96
! 	    EMSG(_("E608: Cannot :throw exceptions with 'Vim' prefix"));
d6ba96
! 	    goto fail;
d6ba96
! 	}
d6ba96
!     }
d6ba96
! 
d6ba96
!     excp = (except_T *)alloc((unsigned)sizeof(except_T));
d6ba96
!     if (excp == NULL)
d6ba96
! 	goto nomem;
d6ba96
  
d6ba96
      if (type == ET_ERROR)
d6ba96
      {
d6ba96
! 	/* Store the original message and prefix the exception value with
d6ba96
! 	 * "Vim:" or, if a command name is given, "Vim(cmdname):". */
d6ba96
! 	excp->messages = (struct msglist *)value;
d6ba96
! 	mesg = excp->messages->throw_msg;
d6ba96
  	if (cmdname != NULL && *cmdname != NUL)
d6ba96
  	{
d6ba96
  	    cmdlen = (int)STRLEN(cmdname);
d6ba96
! 	    excp->value = vim_strnsave((char_u *)"Vim(",
d6ba96
  					   4 + cmdlen + 2 + (int)STRLEN(mesg));
d6ba96
! 	    if (excp->value == NULL)
d6ba96
! 		goto nomem;
d6ba96
! 	    STRCPY(&excp->value[4], cmdname);
d6ba96
! 	    STRCPY(&excp->value[4 + cmdlen], "):");
d6ba96
! 	    val = excp->value + 4 + cmdlen + 2;
d6ba96
  	}
d6ba96
  	else
d6ba96
  	{
d6ba96
! 	    excp->value = vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg));
d6ba96
! 	    if (excp->value == NULL)
d6ba96
! 		goto nomem;
d6ba96
! 	    val = excp->value + 4;
d6ba96
  	}
d6ba96
  
d6ba96
  	/* msg_add_fname may have been used to prefix the message with a file
d6ba96
--- 421,461 ----
d6ba96
      return TRUE;
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
!  * Get an exception message that is to be stored in current_exception->value.
d6ba96
   */
d6ba96
!     char_u *
d6ba96
! get_exception_string(value, type, cmdname, should_free)
d6ba96
      void	*value;
d6ba96
      int		type;
d6ba96
      char_u	*cmdname;
d6ba96
+     int		*should_free;
d6ba96
  {
d6ba96
!     char_u	*ret, *mesg;
d6ba96
      int		cmdlen;
d6ba96
!     char_u	*p, *val;
d6ba96
  
d6ba96
      if (type == ET_ERROR)
d6ba96
      {
d6ba96
! 	*should_free = FALSE;
d6ba96
! 	mesg = ((struct msglist *)value)->throw_msg;
d6ba96
  	if (cmdname != NULL && *cmdname != NUL)
d6ba96
  	{
d6ba96
  	    cmdlen = (int)STRLEN(cmdname);
d6ba96
! 	    ret = vim_strnsave((char_u *)"Vim(",
d6ba96
  					   4 + cmdlen + 2 + (int)STRLEN(mesg));
d6ba96
! 	    if (ret == NULL)
d6ba96
! 		return ret;
d6ba96
! 	    STRCPY(&ret[4], cmdname);
d6ba96
! 	    STRCPY(&ret[4 + cmdlen], "):");
d6ba96
! 	    val = ret + 4 + cmdlen + 2;
d6ba96
  	}
d6ba96
  	else
d6ba96
  	{
d6ba96
! 	    ret = vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg));
d6ba96
! 	    if (ret == NULL)
d6ba96
! 		return ret;
d6ba96
! 	    val = ret + 4;
d6ba96
  	}
d6ba96
  
d6ba96
  	/* msg_add_fname may have been used to prefix the message with a file
d6ba96
***************
d6ba96
*** 506,519 ****
d6ba96
  	}
d6ba96
      }
d6ba96
      else
d6ba96
! 	excp->value = value;
d6ba96
  
d6ba96
      excp->type = type;
d6ba96
      excp->throw_name = vim_strsave(sourcing_name == NULL
d6ba96
  					      ? (char_u *)"" : sourcing_name);
d6ba96
      if (excp->throw_name == NULL)
d6ba96
      {
d6ba96
! 	if (type == ET_ERROR)
d6ba96
  	    vim_free(excp->value);
d6ba96
  	goto nomem;
d6ba96
      }
d6ba96
--- 492,556 ----
d6ba96
  	}
d6ba96
      }
d6ba96
      else
d6ba96
!     {
d6ba96
! 	*should_free = FALSE;
d6ba96
! 	ret = (char_u *) value;
d6ba96
!     }
d6ba96
! 
d6ba96
!     return ret;
d6ba96
! }
d6ba96
! 
d6ba96
! 
d6ba96
! /*
d6ba96
!  * Throw a new exception.  Return FAIL when out of memory or it was tried to
d6ba96
!  * throw an illegal user exception.  "value" is the exception string for a
d6ba96
!  * user or interrupt exception, or points to a message list in case of an
d6ba96
!  * error exception.
d6ba96
!  */
d6ba96
!     static int
d6ba96
! throw_exception(value, type, cmdname)
d6ba96
!     void	*value;
d6ba96
!     int		type;
d6ba96
!     char_u	*cmdname;
d6ba96
! {
d6ba96
!     except_T	*excp;
d6ba96
!     int		should_free;
d6ba96
! 
d6ba96
!     /*
d6ba96
!      * Disallow faking Interrupt or error exceptions as user exceptions.  They
d6ba96
!      * would be treated differently from real interrupt or error exceptions
d6ba96
!      * when no active try block is found, see do_cmdline().
d6ba96
!      */
d6ba96
!     if (type == ET_USER)
d6ba96
!     {
d6ba96
! 	if (STRNCMP((char_u *)value, "Vim", 3) == 0
d6ba96
! 		&& (((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':'
d6ba96
! 		    || ((char_u *)value)[3] == '('))
d6ba96
! 	{
d6ba96
! 	    EMSG(_("E608: Cannot :throw exceptions with 'Vim' prefix"));
d6ba96
! 	    goto fail;
d6ba96
! 	}
d6ba96
!     }
d6ba96
! 
d6ba96
!     excp = (except_T *)alloc((unsigned)sizeof(except_T));
d6ba96
!     if (excp == NULL)
d6ba96
! 	goto nomem;
d6ba96
! 
d6ba96
!     if (type == ET_ERROR)
d6ba96
! 	/* Store the original message and prefix the exception value with
d6ba96
! 	 * "Vim:" or, if a command name is given, "Vim(cmdname):". */
d6ba96
! 	excp->messages = (struct msglist *)value;
d6ba96
! 
d6ba96
!     excp->value = get_exception_string(value, type, cmdname, &should_free);
d6ba96
!     if (excp->value == NULL && should_free)
d6ba96
! 	goto nomem;
d6ba96
  
d6ba96
      excp->type = type;
d6ba96
      excp->throw_name = vim_strsave(sourcing_name == NULL
d6ba96
  					      ? (char_u *)"" : sourcing_name);
d6ba96
      if (excp->throw_name == NULL)
d6ba96
      {
d6ba96
! 	if (should_free)
d6ba96
  	    vim_free(excp->value);
d6ba96
  	goto nomem;
d6ba96
      }
d6ba96
***************
d6ba96
*** 2033,2042 ****
d6ba96
  	/* If an error was about to be converted to an exception when
d6ba96
  	 * enter_cleanup() was called, free the message list. */
d6ba96
  	if (msg_list != NULL)
d6ba96
! 	{
d6ba96
! 	    free_msglist(*msg_list);
d6ba96
! 	    *msg_list = NULL;
d6ba96
! 	}
d6ba96
      }
d6ba96
  
d6ba96
      /*
d6ba96
--- 2070,2076 ----
d6ba96
  	/* If an error was about to be converted to an exception when
d6ba96
  	 * enter_cleanup() was called, free the message list. */
d6ba96
  	if (msg_list != NULL)
d6ba96
! 	    free_global_msglist();
d6ba96
      }
d6ba96
  
d6ba96
      /*
d6ba96
*** ../vim-7.4.106/src/if_py_both.h	2013-11-11 01:05:43.000000000 +0100
d6ba96
--- src/if_py_both.h	2013-11-28 17:00:22.000000000 +0100
d6ba96
***************
d6ba96
*** 566,571 ****
d6ba96
--- 566,593 ----
d6ba96
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
d6ba96
  	return -1;
d6ba96
      }
d6ba96
+     else if (msg_list != NULL && *msg_list != NULL)
d6ba96
+     {
d6ba96
+ 	int	should_free;
d6ba96
+ 	char_u	*msg;
d6ba96
+ 
d6ba96
+ 	msg = get_exception_string(*msg_list, ET_ERROR, NULL, &should_free);
d6ba96
+ 
d6ba96
+ 	if (msg == NULL)
d6ba96
+ 	{
d6ba96
+ 	    PyErr_NoMemory();
d6ba96
+ 	    return -1;
d6ba96
+ 	}
d6ba96
+ 
d6ba96
+ 	PyErr_SetVim((char *) msg);
d6ba96
+ 
d6ba96
+ 	free_global_msglist();
d6ba96
+ 
d6ba96
+ 	if (should_free)
d6ba96
+ 	    vim_free(msg);
d6ba96
+ 
d6ba96
+ 	return -1;
d6ba96
+     }
d6ba96
      else if (!did_throw)
d6ba96
  	return (PyErr_Occurred() ? -1 : 0);
d6ba96
      /* Python exception is preferred over vim one; unlikely to occur though */
d6ba96
*** ../vim-7.4.106/src/proto/ex_eval.pro	2013-08-10 13:37:10.000000000 +0200
d6ba96
--- src/proto/ex_eval.pro	2013-11-28 16:56:33.000000000 +0100
d6ba96
***************
d6ba96
*** 4,11 ****
d6ba96
--- 4,13 ----
d6ba96
  int should_abort __ARGS((int retcode));
d6ba96
  int aborted_in_try __ARGS((void));
d6ba96
  int cause_errthrow __ARGS((char_u *mesg, int severe, int *ignore));
d6ba96
+ void free_global_msglist __ARGS((void));
d6ba96
  void do_errthrow __ARGS((struct condstack *cstack, char_u *cmdname));
d6ba96
  int do_intthrow __ARGS((struct condstack *cstack));
d6ba96
+ char_u *get_exception_string __ARGS((void *value, int type, char_u *cmdname, int *should_free));
d6ba96
  void discard_current_exception __ARGS((void));
d6ba96
  void report_make_pending __ARGS((int pending, void *value));
d6ba96
  void report_resume_pending __ARGS((int pending, void *value));
d6ba96
*** ../vim-7.4.106/src/testdir/test86.in	2013-11-11 01:05:43.000000000 +0100
d6ba96
--- src/testdir/test86.in	2013-11-28 16:41:01.000000000 +0100
d6ba96
***************
d6ba96
*** 179,184 ****
d6ba96
--- 179,210 ----
d6ba96
  :unlockvar! l
d6ba96
  :"
d6ba96
  :" Function calls
d6ba96
+ py << EOF
d6ba96
+ import sys
d6ba96
+ def ee(expr, g=globals(), l=locals()):
d6ba96
+     try:
d6ba96
+         exec(expr, g, l)
d6ba96
+     except:
d6ba96
+         ei = sys.exc_info()
d6ba96
+         msg = sys.exc_info()[0].__name__ + ':' + repr(sys.exc_info()[1].args)
d6ba96
+         msg = msg.replace('TypeError:(\'argument 1 ', 'TypeError:(\'')
d6ba96
+         if expr.find('None') > -1:
d6ba96
+             msg = msg.replace('TypeError:(\'iteration over non-sequence\',)',
d6ba96
+                               'TypeError:("\'NoneType\' object is not iterable",)')
d6ba96
+         if expr.find('FailingNumber') > -1:
d6ba96
+             msg = msg.replace(', not \'FailingNumber\'', '').replace('"', '\'')
d6ba96
+             msg = msg.replace('TypeError:(\'iteration over non-sequence\',)',
d6ba96
+                               'TypeError:("\'FailingNumber\' object is not iterable",)')
d6ba96
+         if msg.find('(\'\'') > -1 or msg.find('(\'can\'t') > -1:
d6ba96
+             msg = msg.replace('(\'', '("').replace('\',)', '",)')
d6ba96
+         if expr == 'fd(self=[])':
d6ba96
+             # HACK: PyMapping_Check changed meaning
d6ba96
+             msg = msg.replace('AttributeError:(\'keys\',)',
d6ba96
+                               'TypeError:(\'unable to convert list to vim dictionary\',)')
d6ba96
+         vim.current.buffer.append(expr + ':' + msg)
d6ba96
+     else:
d6ba96
+         vim.current.buffer.append(expr + ':NOT FAILED')
d6ba96
+ EOF
d6ba96
  :fun New(...)
d6ba96
  :   return ['NewStart']+a:000+['NewEnd']
d6ba96
  :endfun
d6ba96
***************
d6ba96
*** 193,210 ****
d6ba96
  :$put =string(l)
d6ba96
  :py l.extend([l[0].name])
d6ba96
  :$put =string(l)
d6ba96
! :try
d6ba96
! :   py l[1](1, 2, 3)
d6ba96
! :catch
d6ba96
! :   $put =v:exception[:16]
d6ba96
! :endtry
d6ba96
  :py f=l[0]
d6ba96
  :delfunction New
d6ba96
! :try
d6ba96
! :   py f(1, 2, 3)
d6ba96
! :catch
d6ba96
! :   $put =v:exception[:16]
d6ba96
! :endtry
d6ba96
  :if has('float')
d6ba96
  :   let l=[0.0]
d6ba96
  :   py l=vim.bindeval('l')
d6ba96
--- 219,228 ----
d6ba96
  :$put =string(l)
d6ba96
  :py l.extend([l[0].name])
d6ba96
  :$put =string(l)
d6ba96
! :py ee('l[1](1, 2, 3)')
d6ba96
  :py f=l[0]
d6ba96
  :delfunction New
d6ba96
! :py ee('f(1, 2, 3)')
d6ba96
  :if has('float')
d6ba96
  :   let l=[0.0]
d6ba96
  :   py l=vim.bindeval('l')
d6ba96
***************
d6ba96
*** 216,222 ****
d6ba96
  :let messages=[]
d6ba96
  :delfunction DictNew
d6ba96
  py <
d6ba96
- import sys
d6ba96
  d=vim.bindeval('{}')
d6ba96
  m=vim.bindeval('messages')
d6ba96
  def em(expr, g=globals(), l=locals()):
d6ba96
--- 234,239 ----
d6ba96
***************
d6ba96
*** 323,328 ****
d6ba96
--- 340,346 ----
d6ba96
  :py l[0] = t.t > 8  # check if the background thread is working
d6ba96
  :py del time
d6ba96
  :py del threading
d6ba96
+ :py del t
d6ba96
  :$put =string(l)
d6ba96
  :"
d6ba96
  :" settrace
d6ba96
***************
d6ba96
*** 882,910 ****
d6ba96
  :fun D()
d6ba96
  :endfun
d6ba96
  py << EOF
d6ba96
- def ee(expr, g=globals(), l=locals()):
d6ba96
-     try:
d6ba96
-         exec(expr, g, l)
d6ba96
-     except:
d6ba96
-         ei = sys.exc_info()
d6ba96
-         msg = sys.exc_info()[0].__name__ + ':' + repr(sys.exc_info()[1].args)
d6ba96
-         msg = msg.replace('TypeError:(\'argument 1 ', 'TypeError:(\'')
d6ba96
-         if expr.find('None') > -1:
d6ba96
-             msg = msg.replace('TypeError:(\'iteration over non-sequence\',)',
d6ba96
-                               'TypeError:("\'NoneType\' object is not iterable",)')
d6ba96
-         if expr.find('FailingNumber') > -1:
d6ba96
-             msg = msg.replace(', not \'FailingNumber\'', '').replace('"', '\'')
d6ba96
-             msg = msg.replace('TypeError:(\'iteration over non-sequence\',)',
d6ba96
-                               'TypeError:("\'FailingNumber\' object is not iterable",)')
d6ba96
-         if msg.find('(\'\'') > -1 or msg.find('(\'can\'t') > -1:
d6ba96
-             msg = msg.replace('(\'', '("').replace('\',)', '",)')
d6ba96
-         if expr == 'fd(self=[])':
d6ba96
-             # HACK: PyMapping_Check changed meaning
d6ba96
-             msg = msg.replace('AttributeError:(\'keys\',)',
d6ba96
-                               'TypeError:(\'unable to convert list to vim dictionary\',)')
d6ba96
-         cb.append(expr + ':' + msg)
d6ba96
-     else:
d6ba96
-         cb.append(expr + ':NOT FAILED')
d6ba96
  d = vim.Dictionary()
d6ba96
  ned = vim.Dictionary(foo='bar', baz='abcD')
d6ba96
  dl = vim.Dictionary(a=1)
d6ba96
--- 900,905 ----
d6ba96
***************
d6ba96
*** 1276,1281 ****
d6ba96
--- 1271,1277 ----
d6ba96
  ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")')
d6ba96
  ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")')
d6ba96
  ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")')
d6ba96
+ ee('vim.eval("xxx_unknown_function_xxx()")')
d6ba96
  ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")')
d6ba96
  del Exe
d6ba96
  EOF
d6ba96
*** ../vim-7.4.106/src/testdir/test86.ok	2013-11-11 01:05:43.000000000 +0100
d6ba96
--- src/testdir/test86.ok	2013-11-28 16:41:01.000000000 +0100
d6ba96
***************
d6ba96
*** 53,60 ****
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
d6ba96
! Vim(python):E725:
d6ba96
! Vim(python):E117:
d6ba96
  [0.0, 0.0]
d6ba96
  KeyError
d6ba96
  TypeError
d6ba96
--- 53,60 ----
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
d6ba96
! l[1](1, 2, 3):error:('Vim:E725: Calling dict function without Dictionary: DictNew',)
d6ba96
! f(1, 2, 3):error:('Vim:E117: Unknown function: New',)
d6ba96
  [0.0, 0.0]
d6ba96
  KeyError
d6ba96
  TypeError
d6ba96
***************
d6ba96
*** 1197,1202 ****
d6ba96
--- 1197,1203 ----
d6ba96
  vim.eval("Exe('throw ''ghi''')"):error:('ghi',)
d6ba96
  vim.eval("Exe('echoerr ''jkl''')"):error:('Vim(echoerr):jkl',)
d6ba96
  vim.eval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
d6ba96
+ vim.eval("xxx_unknown_function_xxx()"):error:('Vim:E117: Unknown function: xxx_unknown_function_xxx',)
d6ba96
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
d6ba96
  Caught KeyboardInterrupt
d6ba96
  Running :put
d6ba96
*** ../vim-7.4.106/src/testdir/test87.in	2013-11-11 01:05:43.000000000 +0100
d6ba96
--- src/testdir/test87.in	2013-11-28 16:41:01.000000000 +0100
d6ba96
***************
d6ba96
*** 172,177 ****
d6ba96
--- 172,207 ----
d6ba96
  :unlockvar! l
d6ba96
  :"
d6ba96
  :" Function calls
d6ba96
+ py3 << EOF
d6ba96
+ import sys
d6ba96
+ import re
d6ba96
+ 
d6ba96
+ py33_type_error_pattern = re.compile('^__call__\(\) takes (\d+) positional argument but (\d+) were given$')
d6ba96
+ 
d6ba96
+ def ee(expr, g=globals(), l=locals()):
d6ba96
+     cb = vim.current.buffer
d6ba96
+     try:
d6ba96
+         try:
d6ba96
+             exec(expr, g, l)
d6ba96
+         except Exception as e:
d6ba96
+             if sys.version_info >= (3, 3) and e.__class__ is AttributeError and str(e).find('has no attribute')>=0 and not str(e).startswith("'vim."):
d6ba96
+                 cb.append(expr + ':' + repr((e.__class__, AttributeError(str(e)[str(e).rfind(" '") + 2:-1]))))
d6ba96
+             elif sys.version_info >= (3, 3) and e.__class__ is ImportError and str(e).find('No module named \'') >= 0:
d6ba96
+                 cb.append(expr + ':' + repr((e.__class__, ImportError(str(e).replace("'", '')))))
d6ba96
+             elif sys.version_info >= (3, 3) and e.__class__ is TypeError:
d6ba96
+                 m = py33_type_error_pattern.search(str(e))
d6ba96
+                 if m:
d6ba96
+                     msg = '__call__() takes exactly {0} positional argument ({1} given)'.format(m.group(1), m.group(2))
d6ba96
+                     cb.append(expr + ':' + repr((e.__class__, TypeError(msg))))
d6ba96
+                 else:
d6ba96
+                     cb.append(expr + ':' + repr((e.__class__, e)))
d6ba96
+             else:
d6ba96
+                 cb.append(expr + ':' + repr((e.__class__, e)))
d6ba96
+         else:
d6ba96
+             cb.append(expr + ':NOT FAILED')
d6ba96
+     except Exception as e:
d6ba96
+         cb.append(expr + '::' + repr((e.__class__, e)))
d6ba96
+ EOF
d6ba96
  :fun New(...)
d6ba96
  :   return ['NewStart']+a:000+['NewEnd']
d6ba96
  :endfun
d6ba96
***************
d6ba96
*** 186,203 ****
d6ba96
  :$put =string(l)
d6ba96
  :py3 l+=[l[0].name]
d6ba96
  :$put =string(l)
d6ba96
! :try
d6ba96
! :   py3 l[1](1, 2, 3)
d6ba96
! :catch
d6ba96
! :   $put =v:exception[:13]
d6ba96
! :endtry
d6ba96
  :py3 f=l[0]
d6ba96
  :delfunction New
d6ba96
! :try
d6ba96
! :   py3 f(1, 2, 3)
d6ba96
! :catch
d6ba96
! :   $put =v:exception[:13]
d6ba96
! :endtry
d6ba96
  :if has('float')
d6ba96
  :   let l=[0.0]
d6ba96
  :   py3 l=vim.bindeval('l')
d6ba96
--- 216,225 ----
d6ba96
  :$put =string(l)
d6ba96
  :py3 l+=[l[0].name]
d6ba96
  :$put =string(l)
d6ba96
! :py3 ee('l[1](1, 2, 3)')
d6ba96
  :py3 f=l[0]
d6ba96
  :delfunction New
d6ba96
! :py3 ee('f(1, 2, 3)')
d6ba96
  :if has('float')
d6ba96
  :   let l=[0.0]
d6ba96
  :   py3 l=vim.bindeval('l')
d6ba96
***************
d6ba96
*** 315,320 ****
d6ba96
--- 337,343 ----
d6ba96
  :py3 l[0] = t.t > 8  # check if the background thread is working
d6ba96
  :py3 del time
d6ba96
  :py3 del threading
d6ba96
+ :py3 del t
d6ba96
  :$put =string(l)
d6ba96
  :"
d6ba96
  :" settrace
d6ba96
***************
d6ba96
*** 829,861 ****
d6ba96
  :fun D()
d6ba96
  :endfun
d6ba96
  py3 << EOF
d6ba96
- import re
d6ba96
- 
d6ba96
- py33_type_error_pattern = re.compile('^__call__\(\) takes (\d+) positional argument but (\d+) were given$')
d6ba96
- 
d6ba96
- def ee(expr, g=globals(), l=locals()):
d6ba96
-     try:
d6ba96
-         try:
d6ba96
-             exec(expr, g, l)
d6ba96
-         except Exception as e:
d6ba96
-             if sys.version_info >= (3, 3) and e.__class__ is AttributeError and str(e).find('has no attribute')>=0 and not str(e).startswith("'vim."):
d6ba96
-                 cb.append(expr + ':' + repr((e.__class__, AttributeError(str(e)[str(e).rfind(" '") + 2:-1]))))
d6ba96
-             elif sys.version_info >= (3, 3) and e.__class__ is ImportError and str(e).find('No module named \'') >= 0:
d6ba96
-                 cb.append(expr + ':' + repr((e.__class__, ImportError(str(e).replace("'", '')))))
d6ba96
-             elif sys.version_info >= (3, 3) and e.__class__ is TypeError:
d6ba96
-                 m = py33_type_error_pattern.search(str(e))
d6ba96
-                 if m:
d6ba96
-                     msg = '__call__() takes exactly {0} positional argument ({1} given)'.format(m.group(1), m.group(2))
d6ba96
-                     cb.append(expr + ':' + repr((e.__class__, TypeError(msg))))
d6ba96
-                 else:
d6ba96
-                     cb.append(expr + ':' + repr((e.__class__, e)))
d6ba96
-             else:
d6ba96
-                 cb.append(expr + ':' + repr((e.__class__, e)))
d6ba96
-         else:
d6ba96
-             cb.append(expr + ':NOT FAILED')
d6ba96
-     except Exception as e:
d6ba96
-         cb.append(expr + '::' + repr((e.__class__, e)))
d6ba96
- 
d6ba96
  d = vim.Dictionary()
d6ba96
  ned = vim.Dictionary(foo='bar', baz='abcD')
d6ba96
  dl = vim.Dictionary(a=1)
d6ba96
--- 852,857 ----
d6ba96
***************
d6ba96
*** 1227,1232 ****
d6ba96
--- 1223,1229 ----
d6ba96
  ee('vim.eval("Exe(\'throw \'\'ghi\'\'\')")')
d6ba96
  ee('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")')
d6ba96
  ee('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")')
d6ba96
+ ee('vim.eval("xxx_unknown_function_xxx()")')
d6ba96
  ee('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")')
d6ba96
  del Exe
d6ba96
  EOF
d6ba96
*** ../vim-7.4.106/src/testdir/test87.ok	2013-11-11 01:05:43.000000000 +0100
d6ba96
--- src/testdir/test87.ok	2013-11-28 16:41:01.000000000 +0100
d6ba96
***************
d6ba96
*** 53,60 ****
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
d6ba96
! Vim(py3):E725:
d6ba96
! Vim(py3):E117:
d6ba96
  [0.0, 0.0]
d6ba96
  KeyError
d6ba96
  TypeError
d6ba96
--- 53,60 ----
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}, 'New']
d6ba96
! l[1](1, 2, 3):(<class 'vim.error'>, error('Vim:E725: Calling dict function without Dictionary: DictNew',))
d6ba96
! f(1, 2, 3):(<class 'vim.error'>, error('Vim:E117: Unknown function: New',))
d6ba96
  [0.0, 0.0]
d6ba96
  KeyError
d6ba96
  TypeError
d6ba96
***************
d6ba96
*** 1186,1191 ****
d6ba96
--- 1186,1192 ----
d6ba96
  vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))
d6ba96
  vim.eval("Exe('echoerr ''jkl''')"):(<class 'vim.error'>, error('Vim(echoerr):jkl',))
d6ba96
  vim.eval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
d6ba96
+ vim.eval("xxx_unknown_function_xxx()"):(<class 'vim.error'>, error('Vim:E117: Unknown function: xxx_unknown_function_xxx',))
d6ba96
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
d6ba96
  Caught KeyboardInterrupt
d6ba96
  Running :put
d6ba96
*** ../vim-7.4.106/src/version.c	2013-11-28 16:32:34.000000000 +0100
d6ba96
--- src/version.c	2013-11-28 16:41:43.000000000 +0100
d6ba96
***************
d6ba96
*** 740,741 ****
d6ba96
--- 740,743 ----
d6ba96
  {   /* Add new patch number below this line */
d6ba96
+ /**/
d6ba96
+     107,
d6ba96
  /**/
d6ba96
d6ba96
-- 
d6ba96
hundred-and-one symptoms of being an internet addict:
d6ba96
8. You spend half of the plane trip with your laptop on your lap...and your
d6ba96
   child in the overhead compartment.
d6ba96
d6ba96
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d6ba96
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d6ba96
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d6ba96
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///