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