jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.107

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