Karsten Hopp 240fd3
To: vim_dev@googlegroups.com
Karsten Hopp 240fd3
Subject: Patch 7.3.1068
Karsten Hopp 240fd3
Fcc: outbox
Karsten Hopp 240fd3
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 240fd3
Mime-Version: 1.0
Karsten Hopp 240fd3
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 240fd3
Content-Transfer-Encoding: 8bit
Karsten Hopp 240fd3
------------
Karsten Hopp 240fd3
Karsten Hopp 240fd3
Patch 7.3.1068
Karsten Hopp 240fd3
Problem:    Python: Script is auto-loaded on function creation.
Karsten Hopp 240fd3
Solution:   Python patch 27. (ZyX)
Karsten Hopp 240fd3
Files:	    src/eval.c, src/if_py_both.h, src/proto/eval.pro,
Karsten Hopp 240fd3
	    src/testdir/test86.ok, src/testdir/test87.ok, src/vim.h
Karsten Hopp 240fd3
Karsten Hopp 240fd3
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/eval.c	2013-05-30 13:14:06.000000000 +0200
Karsten Hopp 240fd3
--- src/eval.c	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 810,815 ****
Karsten Hopp 240fd3
--- 810,816 ----
Karsten Hopp 240fd3
  # endif
Karsten Hopp 240fd3
  	prof_self_cmp __ARGS((const void *s1, const void *s2));
Karsten Hopp 240fd3
  #endif
Karsten Hopp 240fd3
+ static int script_autoload __ARGS((char_u *name, int reload));
Karsten Hopp 240fd3
  static char_u *autoload_name __ARGS((char_u *name));
Karsten Hopp 240fd3
  static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
Karsten Hopp 240fd3
  static void func_free __ARGS((ufunc_T *fp));
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 829,838 ****
Karsten Hopp 240fd3
  static void sortFunctions __ARGS(());
Karsten Hopp 240fd3
  #endif
Karsten Hopp 240fd3
  
Karsten Hopp 240fd3
- 
Karsten Hopp 240fd3
- /* Character used as separated in autoload function/variable names. */
Karsten Hopp 240fd3
- #define AUTOLOAD_CHAR '#'
Karsten Hopp 240fd3
- 
Karsten Hopp 240fd3
  /*
Karsten Hopp 240fd3
   * Initialize the global and v: variables.
Karsten Hopp 240fd3
   */
Karsten Hopp 240fd3
--- 830,835 ----
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 22190,22196 ****
Karsten Hopp 240fd3
   * If "name" has a package name try autoloading the script for it.
Karsten Hopp 240fd3
   * Return TRUE if a package was loaded.
Karsten Hopp 240fd3
   */
Karsten Hopp 240fd3
!     int
Karsten Hopp 240fd3
  script_autoload(name, reload)
Karsten Hopp 240fd3
      char_u	*name;
Karsten Hopp 240fd3
      int		reload;	    /* load script again when already loaded */
Karsten Hopp 240fd3
--- 22187,22193 ----
Karsten Hopp 240fd3
   * If "name" has a package name try autoloading the script for it.
Karsten Hopp 240fd3
   * Return TRUE if a package was loaded.
Karsten Hopp 240fd3
   */
Karsten Hopp 240fd3
!     static int
Karsten Hopp 240fd3
  script_autoload(name, reload)
Karsten Hopp 240fd3
      char_u	*name;
Karsten Hopp 240fd3
      int		reload;	    /* load script again when already loaded */
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/if_py_both.h	2013-05-30 13:22:07.000000000 +0200
Karsten Hopp 240fd3
--- src/if_py_both.h	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 2015,2033 ****
Karsten Hopp 240fd3
  	func_ref(self->name);
Karsten Hopp 240fd3
      }
Karsten Hopp 240fd3
      else
Karsten Hopp 240fd3
!     {
Karsten Hopp 240fd3
! 	self->name = get_expanded_name(name, TRUE);
Karsten Hopp 240fd3
! 	if (self->name == NULL)
Karsten Hopp 240fd3
  	{
Karsten Hopp 240fd3
! 	    if (script_autoload(name, TRUE) && !aborting())
Karsten Hopp 240fd3
! 		self->name = get_expanded_name(name, TRUE);
Karsten Hopp 240fd3
! 	    if (self->name == NULL)
Karsten Hopp 240fd3
! 	    {
Karsten Hopp 240fd3
! 		PyErr_SetString(PyExc_ValueError, _("function does not exist"));
Karsten Hopp 240fd3
! 		return NULL;
Karsten Hopp 240fd3
! 	    }
Karsten Hopp 240fd3
  	}
Karsten Hopp 240fd3
-     }
Karsten Hopp 240fd3
  
Karsten Hopp 240fd3
      return (PyObject *)(self);
Karsten Hopp 240fd3
  }
Karsten Hopp 240fd3
--- 2015,2027 ----
Karsten Hopp 240fd3
  	func_ref(self->name);
Karsten Hopp 240fd3
      }
Karsten Hopp 240fd3
      else
Karsten Hopp 240fd3
! 	if ((self->name = get_expanded_name(name,
Karsten Hopp 240fd3
! 				    vim_strchr(name, AUTOLOAD_CHAR) == NULL))
Karsten Hopp 240fd3
! 		== NULL)
Karsten Hopp 240fd3
  	{
Karsten Hopp 240fd3
! 	    PyErr_SetString(PyExc_ValueError, _("function does not exist"));
Karsten Hopp 240fd3
! 	    return NULL;
Karsten Hopp 240fd3
  	}
Karsten Hopp 240fd3
  
Karsten Hopp 240fd3
      return (PyObject *)(self);
Karsten Hopp 240fd3
  }
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/proto/eval.pro	2013-05-30 13:14:06.000000000 +0200
Karsten Hopp 240fd3
--- src/proto/eval.pro	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 132,136 ****
Karsten Hopp 240fd3
  void ex_oldfiles __ARGS((exarg_T *eap));
Karsten Hopp 240fd3
  int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
Karsten Hopp 240fd3
  char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
Karsten Hopp 240fd3
- int script_autoload __ARGS((char_u *name, int reload));
Karsten Hopp 240fd3
  /* vim: set ft=c : */
Karsten Hopp 240fd3
--- 132,135 ----
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/testdir/test86.ok	2013-05-30 13:28:37.000000000 +0200
Karsten Hopp 240fd3
--- src/testdir/test86.ok	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 889,895 ****
Karsten Hopp 240fd3
  >> FunctionConstructor
Karsten Hopp 240fd3
  vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',))
Karsten Hopp 240fd3
  vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
! vim.Function("xxx#non#existent#function#xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
  >> FunctionCall
Karsten Hopp 240fd3
  >>> Testing StringToChars using f({%s : 1})
Karsten Hopp 240fd3
  f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))
Karsten Hopp 240fd3
--- 889,895 ----
Karsten Hopp 240fd3
  >> FunctionConstructor
Karsten Hopp 240fd3
  vim.Function("123"):(<type 'exceptions.ValueError'>, ValueError('unnamed function does not exist',))
Karsten Hopp 240fd3
  vim.Function("xxx_non_existent_function_xxx"):(<type 'exceptions.ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
! vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
Karsten Hopp 240fd3
  >> FunctionCall
Karsten Hopp 240fd3
  >>> Testing StringToChars using f({%s : 1})
Karsten Hopp 240fd3
  f({1 : 1}):(<type 'exceptions.TypeError'>, TypeError('object must be string',))
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/testdir/test87.ok	2013-05-30 13:28:37.000000000 +0200
Karsten Hopp 240fd3
--- src/testdir/test87.ok	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 878,884 ****
Karsten Hopp 240fd3
  >> FunctionConstructor
Karsten Hopp 240fd3
  vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',))
Karsten Hopp 240fd3
  vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
! vim.Function("xxx#non#existent#function#xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
  >> FunctionCall
Karsten Hopp 240fd3
  >>> Testing StringToChars using f({%s : 1})
Karsten Hopp 240fd3
  f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 240fd3
--- 878,884 ----
Karsten Hopp 240fd3
  >> FunctionConstructor
Karsten Hopp 240fd3
  vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function does not exist',))
Karsten Hopp 240fd3
  vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function does not exist',))
Karsten Hopp 240fd3
! vim.Function("xxx#non#existent#function#xxx"):NOT FAILED
Karsten Hopp 240fd3
  >> FunctionCall
Karsten Hopp 240fd3
  >>> Testing StringToChars using f({%s : 1})
Karsten Hopp 240fd3
  f({1 : 1}):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/vim.h	2013-05-06 03:52:44.000000000 +0200
Karsten Hopp 240fd3
--- src/vim.h	2013-05-30 13:35:15.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 2243,2246 ****
Karsten Hopp 240fd3
--- 2243,2249 ----
Karsten Hopp 240fd3
  #define SREQ_WIN	1	/* Request window-local option */
Karsten Hopp 240fd3
  #define SREQ_BUF	2	/* Request buffer-local option */
Karsten Hopp 240fd3
  
Karsten Hopp 240fd3
+ /* Character used as separated in autoload function/variable names. */
Karsten Hopp 240fd3
+ #define AUTOLOAD_CHAR '#'
Karsten Hopp 240fd3
+ 
Karsten Hopp 240fd3
  #endif /* VIM__H */
Karsten Hopp 240fd3
*** ../vim-7.3.1067/src/version.c	2013-05-30 13:32:26.000000000 +0200
Karsten Hopp 240fd3
--- src/version.c	2013-05-30 13:34:44.000000000 +0200
Karsten Hopp 240fd3
***************
Karsten Hopp 240fd3
*** 730,731 ****
Karsten Hopp 240fd3
--- 730,733 ----
Karsten Hopp 240fd3
  {   /* Add new patch number below this line */
Karsten Hopp 240fd3
+ /**/
Karsten Hopp 240fd3
+     1068,
Karsten Hopp 240fd3
  /**/
Karsten Hopp 240fd3
Karsten Hopp 240fd3
-- 
Karsten Hopp 240fd3
How To Keep A Healthy Level Of Insanity:
Karsten Hopp 240fd3
10. Ask people what sex they are. Laugh hysterically after they answer.
Karsten Hopp 240fd3
Karsten Hopp 240fd3
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 240fd3
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 240fd3
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 240fd3
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///