Karsten Hopp 05b757
To: vim_dev@googlegroups.com
Karsten Hopp 05b757
Subject: Patch 7.3.1063
Karsten Hopp 05b757
Fcc: outbox
Karsten Hopp 05b757
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 05b757
Mime-Version: 1.0
Karsten Hopp 05b757
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 05b757
Content-Transfer-Encoding: 8bit
Karsten Hopp 05b757
------------
Karsten Hopp 05b757
Karsten Hopp 05b757
Patch 7.3.1063
Karsten Hopp 05b757
Problem:    Python: Function is not standard.
Karsten Hopp 05b757
Solution:   Python patch 22: make Function subclassable. (ZyX)
Karsten Hopp 05b757
Files:	    src/eval.c, src/if_py_both.h, src/proto/eval.pro,
Karsten Hopp 05b757
	    src/testdir/test86.in, src/testdir/test86.ok,
Karsten Hopp 05b757
	    src/testdir/test87.in, src/testdir/test87.ok
Karsten Hopp 05b757
Karsten Hopp 05b757
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/eval.c	2013-05-30 13:01:14.000000000 +0200
Karsten Hopp 05b757
--- src/eval.c	2013-05-30 13:13:53.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 21933,21938 ****
Karsten Hopp 05b757
--- 21933,21947 ----
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
  #endif
Karsten Hopp 05b757
  
Karsten Hopp 05b757
+     int
Karsten Hopp 05b757
+ translated_function_exists(name)
Karsten Hopp 05b757
+     char_u	*name;
Karsten Hopp 05b757
+ {
Karsten Hopp 05b757
+     if (builtin_function(name))
Karsten Hopp 05b757
+ 	return find_internal_func(name) >= 0;
Karsten Hopp 05b757
+     return find_func(name) != NULL;
Karsten Hopp 05b757
+ }
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
  /*
Karsten Hopp 05b757
   * Return TRUE if a function "name" exists.
Karsten Hopp 05b757
   */
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 21950,21961 ****
Karsten Hopp 05b757
      /* Only accept "funcname", "funcname ", "funcname (..." and
Karsten Hopp 05b757
       * "funcname(...", not "funcname!...". */
Karsten Hopp 05b757
      if (p != NULL && (*nm == NUL || *nm == '('))
Karsten Hopp 05b757
!     {
Karsten Hopp 05b757
! 	if (builtin_function(p))
Karsten Hopp 05b757
! 	    n = (find_internal_func(p) >= 0);
Karsten Hopp 05b757
! 	else
Karsten Hopp 05b757
! 	    n = (find_func(p) != NULL);
Karsten Hopp 05b757
!     }
Karsten Hopp 05b757
      vim_free(p);
Karsten Hopp 05b757
      return n;
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
--- 21959,21965 ----
Karsten Hopp 05b757
      /* Only accept "funcname", "funcname ", "funcname (..." and
Karsten Hopp 05b757
       * "funcname(...", not "funcname!...". */
Karsten Hopp 05b757
      if (p != NULL && (*nm == NUL || *nm == '('))
Karsten Hopp 05b757
! 	n = translated_function_exists(p);
Karsten Hopp 05b757
      vim_free(p);
Karsten Hopp 05b757
      return n;
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 21971,21988 ****
Karsten Hopp 05b757
      p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      if (p != NULL && *nm == NUL)
Karsten Hopp 05b757
!     {
Karsten Hopp 05b757
! 	if (!check)
Karsten Hopp 05b757
  	    return p;
Karsten Hopp 05b757
! 	else if (builtin_function(p))
Karsten Hopp 05b757
! 	{
Karsten Hopp 05b757
! 	    if (find_internal_func(p) >= 0)
Karsten Hopp 05b757
! 		return p;
Karsten Hopp 05b757
! 	}
Karsten Hopp 05b757
! 	else
Karsten Hopp 05b757
! 	    if (find_func(p) != NULL)
Karsten Hopp 05b757
! 		return p;
Karsten Hopp 05b757
!     }
Karsten Hopp 05b757
      vim_free(p);
Karsten Hopp 05b757
      return NULL;
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
--- 21975,21983 ----
Karsten Hopp 05b757
      p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      if (p != NULL && *nm == NUL)
Karsten Hopp 05b757
! 	if (!check || translated_function_exists(p))
Karsten Hopp 05b757
  	    return p;
Karsten Hopp 05b757
! 
Karsten Hopp 05b757
      vim_free(p);
Karsten Hopp 05b757
      return NULL;
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/if_py_both.h	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/if_py_both.h	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 1991,2020 ****
Karsten Hopp 05b757
  
Karsten Hopp 05b757
  static PyTypeObject FunctionType;
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      static PyObject *
Karsten Hopp 05b757
! FunctionNew(char_u *name)
Karsten Hopp 05b757
  {
Karsten Hopp 05b757
      FunctionObject	*self;
Karsten Hopp 05b757
  
Karsten Hopp 05b757
!     self = PyObject_NEW(FunctionObject, &FunctionType);
Karsten Hopp 05b757
      if (self == NULL)
Karsten Hopp 05b757
  	return NULL;
Karsten Hopp 05b757
!     self->name = PyMem_New(char_u, STRLEN(name) + 1);
Karsten Hopp 05b757
!     if (self->name == NULL)
Karsten Hopp 05b757
      {
Karsten Hopp 05b757
! 	PyErr_NoMemory();
Karsten Hopp 05b757
! 	return NULL;
Karsten Hopp 05b757
      }
Karsten Hopp 05b757
!     STRCPY(self->name, name);
Karsten Hopp 05b757
!     func_ref(name);
Karsten Hopp 05b757
      return (PyObject *)(self);
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      static void
Karsten Hopp 05b757
  FunctionDestructor(FunctionObject *self)
Karsten Hopp 05b757
  {
Karsten Hopp 05b757
      func_unref(self->name);
Karsten Hopp 05b757
!     PyMem_Free(self->name);
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      DESTRUCTOR_FINISH(self);
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
--- 1991,2063 ----
Karsten Hopp 05b757
  
Karsten Hopp 05b757
  static PyTypeObject FunctionType;
Karsten Hopp 05b757
  
Karsten Hopp 05b757
+ #define NEW_FUNCTION(name) FunctionNew(&FunctionType, name)
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
      static PyObject *
Karsten Hopp 05b757
! FunctionNew(PyTypeObject *subtype, char_u *name)
Karsten Hopp 05b757
  {
Karsten Hopp 05b757
      FunctionObject	*self;
Karsten Hopp 05b757
  
Karsten Hopp 05b757
!     self = (FunctionObject *) subtype->tp_alloc(subtype, 0);
Karsten Hopp 05b757
! 
Karsten Hopp 05b757
      if (self == NULL)
Karsten Hopp 05b757
  	return NULL;
Karsten Hopp 05b757
! 
Karsten Hopp 05b757
!     if (isdigit(*name))
Karsten Hopp 05b757
      {
Karsten Hopp 05b757
! 	if (!translated_function_exists(name))
Karsten Hopp 05b757
! 	{
Karsten Hopp 05b757
! 	    PyErr_SetString(PyExc_ValueError,
Karsten Hopp 05b757
! 		    _("unnamed function does not exist"));
Karsten Hopp 05b757
! 	    return NULL;
Karsten Hopp 05b757
! 	}
Karsten Hopp 05b757
! 	self->name = vim_strsave(name);
Karsten Hopp 05b757
! 	func_ref(self->name);
Karsten Hopp 05b757
      }
Karsten Hopp 05b757
!     else
Karsten Hopp 05b757
!     {
Karsten Hopp 05b757
! 	self->name = get_expanded_name(name, TRUE);
Karsten Hopp 05b757
! 	if (self->name == NULL)
Karsten Hopp 05b757
! 	{
Karsten Hopp 05b757
! 	    if (script_autoload(name, TRUE) && !aborting())
Karsten Hopp 05b757
! 		self->name = get_expanded_name(name, TRUE);
Karsten Hopp 05b757
! 	    if (self->name == NULL)
Karsten Hopp 05b757
! 	    {
Karsten Hopp 05b757
! 		PyErr_SetString(PyExc_ValueError, _("function does not exist"));
Karsten Hopp 05b757
! 		return NULL;
Karsten Hopp 05b757
! 	    }
Karsten Hopp 05b757
! 	}
Karsten Hopp 05b757
!     }
Karsten Hopp 05b757
! 
Karsten Hopp 05b757
      return (PyObject *)(self);
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
  
Karsten Hopp 05b757
+     static PyObject *
Karsten Hopp 05b757
+ FunctionConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
Karsten Hopp 05b757
+ {
Karsten Hopp 05b757
+     PyObject	*self;
Karsten Hopp 05b757
+     char_u	*name;
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+     if (kwargs)
Karsten Hopp 05b757
+     {
Karsten Hopp 05b757
+ 	PyErr_SetString(PyExc_TypeError,
Karsten Hopp 05b757
+ 		_("function constructor does not accept keyword arguments"));
Karsten Hopp 05b757
+ 	return NULL;
Karsten Hopp 05b757
+     }
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+     if (!PyArg_ParseTuple(args, "s", &name))
Karsten Hopp 05b757
+ 	return NULL;
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+     self = FunctionNew(subtype, name);
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+     return self;
Karsten Hopp 05b757
+ }
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
      static void
Karsten Hopp 05b757
  FunctionDestructor(FunctionObject *self)
Karsten Hopp 05b757
  {
Karsten Hopp 05b757
      func_unref(self->name);
Karsten Hopp 05b757
!     vim_free(self->name);
Karsten Hopp 05b757
  
Karsten Hopp 05b757
      DESTRUCTOR_FINISH(self);
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 2093,2099 ****
Karsten Hopp 05b757
  }
Karsten Hopp 05b757
  
Karsten Hopp 05b757
  static struct PyMethodDef FunctionMethods[] = {
Karsten Hopp 05b757
-     {"__call__",(PyCFunction)FunctionCall,  METH_VARARGS|METH_KEYWORDS,	""},
Karsten Hopp 05b757
      {"__dir__",	(PyCFunction)FunctionDir,   METH_NOARGS,		""},
Karsten Hopp 05b757
      { NULL,	NULL,			0,				NULL}
Karsten Hopp 05b757
  };
Karsten Hopp 05b757
--- 2136,2141 ----
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 4895,4901 ****
Karsten Hopp 05b757
  	case VAR_DICT:
Karsten Hopp 05b757
  	    return NEW_DICTIONARY(tv->vval.v_dict);
Karsten Hopp 05b757
  	case VAR_FUNC:
Karsten Hopp 05b757
! 	    return FunctionNew(tv->vval.v_string == NULL
Karsten Hopp 05b757
  					  ? (char_u *)"" : tv->vval.v_string);
Karsten Hopp 05b757
  	case VAR_UNKNOWN:
Karsten Hopp 05b757
  	    Py_INCREF(Py_None);
Karsten Hopp 05b757
--- 4937,4943 ----
Karsten Hopp 05b757
  	case VAR_DICT:
Karsten Hopp 05b757
  	    return NEW_DICTIONARY(tv->vval.v_dict);
Karsten Hopp 05b757
  	case VAR_FUNC:
Karsten Hopp 05b757
! 	    return NEW_FUNCTION(tv->vval.v_string == NULL
Karsten Hopp 05b757
  					  ? (char_u *)"" : tv->vval.v_string);
Karsten Hopp 05b757
  	case VAR_UNKNOWN:
Karsten Hopp 05b757
  	    Py_INCREF(Py_None);
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 5105,5114 ****
Karsten Hopp 05b757
      FunctionType.tp_basicsize = sizeof(FunctionObject);
Karsten Hopp 05b757
      FunctionType.tp_dealloc = (destructor)FunctionDestructor;
Karsten Hopp 05b757
      FunctionType.tp_call = (ternaryfunc)FunctionCall;
Karsten Hopp 05b757
!     FunctionType.tp_flags = Py_TPFLAGS_DEFAULT;
Karsten Hopp 05b757
      FunctionType.tp_doc = "object that calls vim function";
Karsten Hopp 05b757
      FunctionType.tp_methods = FunctionMethods;
Karsten Hopp 05b757
      FunctionType.tp_repr = (reprfunc)FunctionRepr;
Karsten Hopp 05b757
  #if PY_MAJOR_VERSION >= 3
Karsten Hopp 05b757
      FunctionType.tp_getattro = (getattrofunc)FunctionGetattro;
Karsten Hopp 05b757
  #else
Karsten Hopp 05b757
--- 5147,5158 ----
Karsten Hopp 05b757
      FunctionType.tp_basicsize = sizeof(FunctionObject);
Karsten Hopp 05b757
      FunctionType.tp_dealloc = (destructor)FunctionDestructor;
Karsten Hopp 05b757
      FunctionType.tp_call = (ternaryfunc)FunctionCall;
Karsten Hopp 05b757
!     FunctionType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE;
Karsten Hopp 05b757
      FunctionType.tp_doc = "object that calls vim function";
Karsten Hopp 05b757
      FunctionType.tp_methods = FunctionMethods;
Karsten Hopp 05b757
      FunctionType.tp_repr = (reprfunc)FunctionRepr;
Karsten Hopp 05b757
+     FunctionType.tp_new = (newfunc)FunctionConstructor;
Karsten Hopp 05b757
+     FunctionType.tp_alloc = (allocfunc)PyType_GenericAlloc;
Karsten Hopp 05b757
  #if PY_MAJOR_VERSION >= 3
Karsten Hopp 05b757
      FunctionType.tp_getattro = (getattrofunc)FunctionGetattro;
Karsten Hopp 05b757
  #else
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/proto/eval.pro	2013-05-30 13:01:14.000000000 +0200
Karsten Hopp 05b757
--- src/proto/eval.pro	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 79,84 ****
Karsten Hopp 05b757
--- 79,85 ----
Karsten Hopp 05b757
  char_u *get_function_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 05b757
  char_u *get_expr_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 05b757
  char_u *get_expanded_name __ARGS((char_u *name, int check));
Karsten Hopp 05b757
+ int translated_function_exists __ARGS((char_u *name));
Karsten Hopp 05b757
  int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
Karsten Hopp 05b757
  void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv));
Karsten Hopp 05b757
  long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/testdir/test86.in	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/testdir/test86.in	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 31,36 ****
Karsten Hopp 05b757
--- 31,39 ----
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Extending Dictionary directly with different types
Karsten Hopp 05b757
  :let d = {}
Karsten Hopp 05b757
+ :fun d.f()
Karsten Hopp 05b757
+ :  return 1
Karsten Hopp 05b757
+ :endfun
Karsten Hopp 05b757
  py << EOF
Karsten Hopp 05b757
  d=vim.bindeval('d')
Karsten Hopp 05b757
  d['1']='asd'
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 44,55 ****
Karsten Hopp 05b757
  dv.sort(key=repr)
Karsten Hopp 05b757
  di.sort(key=repr)
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
  :$put =pyeval('repr(dk)')
Karsten Hopp 05b757
  :$put =substitute(pyeval('repr(dv)'),'0x\x\+','','g')
Karsten Hopp 05b757
  :$put =substitute(pyeval('repr(di)'),'0x\x\+','','g')
Karsten Hopp 05b757
! :for [key, val] in sort(items(d))
Karsten Hopp 05b757
! :  $put =string(key) . ' : ' . string(val)
Karsten Hopp 05b757
! :  unlet key val
Karsten Hopp 05b757
  :endfor
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" removing items with del
Karsten Hopp 05b757
--- 47,59 ----
Karsten Hopp 05b757
  dv.sort(key=repr)
Karsten Hopp 05b757
  di.sort(key=repr)
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
+ :$put =pyeval('d[''f''](self={})')
Karsten Hopp 05b757
  :$put =pyeval('repr(dk)')
Karsten Hopp 05b757
  :$put =substitute(pyeval('repr(dv)'),'0x\x\+','','g')
Karsten Hopp 05b757
  :$put =substitute(pyeval('repr(di)'),'0x\x\+','','g')
Karsten Hopp 05b757
! :for [key, Val] in sort(items(d))
Karsten Hopp 05b757
! :  $put =string(key) . ' : ' . string(Val)
Karsten Hopp 05b757
! :  unlet key Val
Karsten Hopp 05b757
  :endfor
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" removing items with del
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 66,71 ****
Karsten Hopp 05b757
--- 70,76 ----
Karsten Hopp 05b757
  :$put =string(l)
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :py del d['-1']
Karsten Hopp 05b757
+ :py del d['f']
Karsten Hopp 05b757
  :$put =string(pyeval('d.get(''b'', 1)'))
Karsten Hopp 05b757
  :$put =string(pyeval('d.pop(''b'')'))
Karsten Hopp 05b757
  :$put =string(pyeval('d.get(''b'', 1)'))
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 187,195 ****
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:16]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
  :delfunction New
Karsten Hopp 05b757
  :try
Karsten Hopp 05b757
! :   py l[0](1, 2, 3)
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:16]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
--- 192,201 ----
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:16]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
+ :py f=l[0]
Karsten Hopp 05b757
  :delfunction New
Karsten Hopp 05b757
  :try
Karsten Hopp 05b757
! :   py f(1, 2, 3)
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:16]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 737,742 ****
Karsten Hopp 05b757
--- 743,749 ----
Karsten Hopp 05b757
  :$put =string(pyeval('vim.Dictionary(((''a'', 1),))'))
Karsten Hopp 05b757
  :$put =string(pyeval('vim.List()'))
Karsten Hopp 05b757
  :$put =string(pyeval('vim.List(iter(''abc''))'))
Karsten Hopp 05b757
+ :$put =string(pyeval('vim.Function(''tr'')'))
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Test stdout/stderr
Karsten Hopp 05b757
  :redir => messages
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 747,752 ****
Karsten Hopp 05b757
--- 754,763 ----
Karsten Hopp 05b757
  :redir END
Karsten Hopp 05b757
  :$put =string(substitute(messages, '\d\+', '', 'g'))
Karsten Hopp 05b757
  :" Test subclassing
Karsten Hopp 05b757
+ :fun Put(...)
Karsten Hopp 05b757
+ :   $put =string(a:000)
Karsten Hopp 05b757
+ :   return a:000
Karsten Hopp 05b757
+ :endfun
Karsten Hopp 05b757
  py << EOF
Karsten Hopp 05b757
  class DupDict(vim.Dictionary):
Karsten Hopp 05b757
      def __setitem__(self, key, value):
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 762,771 ****
Karsten Hopp 05b757
--- 773,789 ----
Karsten Hopp 05b757
  dl = DupList()
Karsten Hopp 05b757
  dl2 = DupList(iter('abc'))
Karsten Hopp 05b757
  dl.extend(dl2[0])
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+ class DupFun(vim.Function):
Karsten Hopp 05b757
+     def __call__(self, arg):
Karsten Hopp 05b757
+         return super(DupFun, self).__call__(arg, arg)
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+ df = DupFun('Put')
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
  :$put =string(sort(keys(pyeval('dd'))))
Karsten Hopp 05b757
  :$put =string(pyeval('dl'))
Karsten Hopp 05b757
  :$put =string(pyeval('dl2'))
Karsten Hopp 05b757
+ :$put =string(pyeval('df(2)'))
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Test exceptions
Karsten Hopp 05b757
  :fun Exe(e)
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/testdir/test86.ok	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/testdir/test86.ok	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 4,16 ****
Karsten Hopp 05b757
  Vim(put):E684:
Karsten Hopp 05b757
  [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
  [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
! ['-1', '0', '1', 'b']
Karsten Hopp 05b757
! ['asd', -1L, <vim.dictionary object at >, <vim.list object at >]
Karsten Hopp 05b757
! [('-1', <vim.dictionary object at >), ('0', -1L), ('1', 'asd'), ('b', <vim.list object at >)]
Karsten Hopp 05b757
  '-1' : {'a': 1}
Karsten Hopp 05b757
  '0' : -1
Karsten Hopp 05b757
  '1' : 'asd'
Karsten Hopp 05b757
  'b' : [1, 2, function('strlen')]
Karsten Hopp 05b757
  [0, function('strlen')]
Karsten Hopp 05b757
  [3]
Karsten Hopp 05b757
  [1, 2, function('strlen')]
Karsten Hopp 05b757
--- 4,18 ----
Karsten Hopp 05b757
  Vim(put):E684:
Karsten Hopp 05b757
  [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
  [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
! 1
Karsten Hopp 05b757
! ['-1', '0', '1', 'b', 'f']
Karsten Hopp 05b757
! ['asd', -1L, <vim.Function '1'>, <vim.dictionary object at >, <vim.list object at >]
Karsten Hopp 05b757
! [('-1', <vim.dictionary object at >), ('0', -1L), ('1', 'asd'), ('b', <vim.list object at >), ('f', <vim.Function '1'>)]
Karsten Hopp 05b757
  '-1' : {'a': 1}
Karsten Hopp 05b757
  '0' : -1
Karsten Hopp 05b757
  '1' : 'asd'
Karsten Hopp 05b757
  'b' : [1, 2, function('strlen')]
Karsten Hopp 05b757
+ 'f' : function('1')
Karsten Hopp 05b757
  [0, function('strlen')]
Karsten Hopp 05b757
  [3]
Karsten Hopp 05b757
  [1, 2, function('strlen')]
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 407,419 ****
Karsten Hopp 05b757
  range:__dir__,__members__,append,end,start
Karsten Hopp 05b757
  dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
Karsten Hopp 05b757
  list:__dir__,__members__,extend,locked
Karsten Hopp 05b757
! function:__call__,__dir__,__members__,softspace
Karsten Hopp 05b757
  output:__dir__,__members__,flush,softspace,write,writelines
Karsten Hopp 05b757
  {}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  []
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
  '
Karsten Hopp 05b757
  abcdef
Karsten Hopp 05b757
  line  :
Karsten Hopp 05b757
--- 409,422 ----
Karsten Hopp 05b757
  range:__dir__,__members__,append,end,start
Karsten Hopp 05b757
  dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
Karsten Hopp 05b757
  list:__dir__,__members__,extend,locked
Karsten Hopp 05b757
! function:__dir__,__members__,softspace
Karsten Hopp 05b757
  output:__dir__,__members__,flush,softspace,write,writelines
Karsten Hopp 05b757
  {}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  []
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
+ function('tr')
Karsten Hopp 05b757
  '
Karsten Hopp 05b757
  abcdef
Karsten Hopp 05b757
  line  :
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 424,429 ****
Karsten Hopp 05b757
--- 427,434 ----
Karsten Hopp 05b757
  ['a', 'dup_a']
Karsten Hopp 05b757
  ['a', 'a']
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
+ [2, 2]
Karsten Hopp 05b757
+ [2, 2]
Karsten Hopp 05b757
  (<class 'vim.error'>, error('abc',))
Karsten Hopp 05b757
  (<class 'vim.error'>, error('def',))
Karsten Hopp 05b757
  (<class 'vim.error'>, error('ghi',))
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/testdir/test87.in	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/testdir/test87.in	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 26,31 ****
Karsten Hopp 05b757
--- 26,34 ----
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Extending Dictionary directly with different types
Karsten Hopp 05b757
  :let d = {}
Karsten Hopp 05b757
+ :fun d.f()
Karsten Hopp 05b757
+ :  return 1
Karsten Hopp 05b757
+ :endfun
Karsten Hopp 05b757
  py3 << EOF
Karsten Hopp 05b757
  d=vim.bindeval('d')
Karsten Hopp 05b757
  d['1']='asd'
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 39,50 ****
Karsten Hopp 05b757
  dv.sort(key=repr)
Karsten Hopp 05b757
  di.sort(key=repr)
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
  :$put =py3eval('repr(dk)')
Karsten Hopp 05b757
  :$put =substitute(py3eval('repr(dv)'),'0x\x\+','','g')
Karsten Hopp 05b757
  :$put =substitute(py3eval('repr(di)'),'0x\x\+','','g')
Karsten Hopp 05b757
! :for [key, val] in sort(items(d))
Karsten Hopp 05b757
! :  $put =string(key) . ' : ' . string(val)
Karsten Hopp 05b757
! :  unlet key val
Karsten Hopp 05b757
  :endfor
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" removing items with del
Karsten Hopp 05b757
--- 42,54 ----
Karsten Hopp 05b757
  dv.sort(key=repr)
Karsten Hopp 05b757
  di.sort(key=repr)
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
+ :$put =py3eval('d[''f''](self={})')
Karsten Hopp 05b757
  :$put =py3eval('repr(dk)')
Karsten Hopp 05b757
  :$put =substitute(py3eval('repr(dv)'),'0x\x\+','','g')
Karsten Hopp 05b757
  :$put =substitute(py3eval('repr(di)'),'0x\x\+','','g')
Karsten Hopp 05b757
! :for [key, Val] in sort(items(d))
Karsten Hopp 05b757
! :  $put =string(key) . ' : ' . string(Val)
Karsten Hopp 05b757
! :  unlet key Val
Karsten Hopp 05b757
  :endfor
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" removing items with del
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 61,66 ****
Karsten Hopp 05b757
--- 65,71 ----
Karsten Hopp 05b757
  :$put =string(l)
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :py3 del d['-1']
Karsten Hopp 05b757
+ :py3 del d['f']
Karsten Hopp 05b757
  :$put =string(py3eval('d.get(''b'', 1)'))
Karsten Hopp 05b757
  :$put =string(py3eval('d.pop(''b'')'))
Karsten Hopp 05b757
  :$put =string(py3eval('d.get(''b'', 1)'))
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 182,190 ****
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:13]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
  :delfunction New
Karsten Hopp 05b757
  :try
Karsten Hopp 05b757
! :   py3 l[0](1, 2, 3)
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:13]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
--- 187,196 ----
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:13]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
+ :py3 f=l[0]
Karsten Hopp 05b757
  :delfunction New
Karsten Hopp 05b757
  :try
Karsten Hopp 05b757
! :   py3 f(1, 2, 3)
Karsten Hopp 05b757
  :catch
Karsten Hopp 05b757
  :   $put =v:exception[:13]
Karsten Hopp 05b757
  :endtry
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 698,703 ****
Karsten Hopp 05b757
--- 704,710 ----
Karsten Hopp 05b757
  :$put =string(py3eval('vim.Dictionary(((''a'', 1),))'))
Karsten Hopp 05b757
  :$put =string(py3eval('vim.List()'))
Karsten Hopp 05b757
  :$put =string(py3eval('vim.List(iter(''abc''))'))
Karsten Hopp 05b757
+ :$put =string(py3eval('vim.Function(''tr'')'))
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Test stdout/stderr
Karsten Hopp 05b757
  :redir => messages
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 708,713 ****
Karsten Hopp 05b757
--- 715,724 ----
Karsten Hopp 05b757
  :redir END
Karsten Hopp 05b757
  :$put =string(substitute(messages, '\d\+', '', 'g'))
Karsten Hopp 05b757
  :" Test subclassing
Karsten Hopp 05b757
+ :fun Put(...)
Karsten Hopp 05b757
+ :   $put =string(a:000)
Karsten Hopp 05b757
+ :   return a:000
Karsten Hopp 05b757
+ :endfun
Karsten Hopp 05b757
  py3 << EOF
Karsten Hopp 05b757
  class DupDict(vim.Dictionary):
Karsten Hopp 05b757
      def __setitem__(self, key, value):
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 723,732 ****
Karsten Hopp 05b757
--- 734,750 ----
Karsten Hopp 05b757
  dl = DupList()
Karsten Hopp 05b757
  dl2 = DupList(iter('abc'))
Karsten Hopp 05b757
  dl.extend(dl2[0])
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+ class DupFun(vim.Function):
Karsten Hopp 05b757
+     def __call__(self, arg):
Karsten Hopp 05b757
+         return super(DupFun, self).__call__(arg, arg)
Karsten Hopp 05b757
+ 
Karsten Hopp 05b757
+ df = DupFun('Put')
Karsten Hopp 05b757
  EOF
Karsten Hopp 05b757
  :$put =string(sort(keys(py3eval('dd'))))
Karsten Hopp 05b757
  :$put =string(py3eval('dl'))
Karsten Hopp 05b757
  :$put =string(py3eval('dl2'))
Karsten Hopp 05b757
+ :$put =string(py3eval('df(2)'))
Karsten Hopp 05b757
  :"
Karsten Hopp 05b757
  :" Test exceptions
Karsten Hopp 05b757
  :fun Exe(e)
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/testdir/test87.ok	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/testdir/test87.ok	2013-05-30 13:08:09.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 4,16 ****
Karsten Hopp 05b757
  Vim(put):E684:
Karsten Hopp 05b757
  [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
  [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
! [b'-1', b'0', b'1', b'b']
Karsten Hopp 05b757
! [-1, <vim.dictionary object at >, <vim.list object at >, b'asd']
Karsten Hopp 05b757
! [(b'-1', <vim.dictionary object at >), (b'0', -1), (b'1', b'asd'), (b'b', <vim.list object at >)]
Karsten Hopp 05b757
  '-1' : {'a': 1}
Karsten Hopp 05b757
  '0' : -1
Karsten Hopp 05b757
  '1' : 'asd'
Karsten Hopp 05b757
  'b' : [1, 2, function('strlen')]
Karsten Hopp 05b757
  [0, function('strlen')]
Karsten Hopp 05b757
  [3]
Karsten Hopp 05b757
  [1, 2, function('strlen')]
Karsten Hopp 05b757
--- 4,18 ----
Karsten Hopp 05b757
  Vim(put):E684:
Karsten Hopp 05b757
  [0, 'as''d', [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
  [0, function('strlen'), [1, 2, function('strlen'), {'a': 1}]]
Karsten Hopp 05b757
! 1
Karsten Hopp 05b757
! [b'-1', b'0', b'1', b'b', b'f']
Karsten Hopp 05b757
! [-1, <vim.Function '1'>, <vim.dictionary object at >, <vim.list object at >, b'asd']
Karsten Hopp 05b757
! [(b'-1', <vim.dictionary object at >), (b'0', -1), (b'1', b'asd'), (b'b', <vim.list object at >), (b'f', <vim.Function '1'>)]
Karsten Hopp 05b757
  '-1' : {'a': 1}
Karsten Hopp 05b757
  '0' : -1
Karsten Hopp 05b757
  '1' : 'asd'
Karsten Hopp 05b757
  'b' : [1, 2, function('strlen')]
Karsten Hopp 05b757
+ 'f' : function('1')
Karsten Hopp 05b757
  [0, function('strlen')]
Karsten Hopp 05b757
  [3]
Karsten Hopp 05b757
  [1, 2, function('strlen')]
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 396,408 ****
Karsten Hopp 05b757
  range:__dir__,append,end,start
Karsten Hopp 05b757
  dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
Karsten Hopp 05b757
  list:__dir__,extend,locked
Karsten Hopp 05b757
! function:__call__,__dir__,softspace
Karsten Hopp 05b757
  output:__dir__,flush,softspace,write,writelines
Karsten Hopp 05b757
  {}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  []
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
  '
Karsten Hopp 05b757
  abcdef
Karsten Hopp 05b757
  line  :
Karsten Hopp 05b757
--- 398,411 ----
Karsten Hopp 05b757
  range:__dir__,append,end,start
Karsten Hopp 05b757
  dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
Karsten Hopp 05b757
  list:__dir__,extend,locked
Karsten Hopp 05b757
! function:__dir__,softspace
Karsten Hopp 05b757
  output:__dir__,flush,softspace,write,writelines
Karsten Hopp 05b757
  {}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  {'a': 1}
Karsten Hopp 05b757
  []
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
+ function('tr')
Karsten Hopp 05b757
  '
Karsten Hopp 05b757
  abcdef
Karsten Hopp 05b757
  line  :
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 413,418 ****
Karsten Hopp 05b757
--- 416,423 ----
Karsten Hopp 05b757
  ['a', 'dup_a']
Karsten Hopp 05b757
  ['a', 'a']
Karsten Hopp 05b757
  ['a', 'b', 'c']
Karsten Hopp 05b757
+ [2, 2]
Karsten Hopp 05b757
+ [2, 2]
Karsten Hopp 05b757
  (<class 'vim.error'>, error('abc',))
Karsten Hopp 05b757
  (<class 'vim.error'>, error('def',))
Karsten Hopp 05b757
  (<class 'vim.error'>, error('ghi',))
Karsten Hopp 05b757
*** ../vim-7.3.1062/src/version.c	2013-05-30 13:05:55.000000000 +0200
Karsten Hopp 05b757
--- src/version.c	2013-05-30 13:07:47.000000000 +0200
Karsten Hopp 05b757
***************
Karsten Hopp 05b757
*** 730,731 ****
Karsten Hopp 05b757
--- 730,733 ----
Karsten Hopp 05b757
  {   /* Add new patch number below this line */
Karsten Hopp 05b757
+ /**/
Karsten Hopp 05b757
+     1063,
Karsten Hopp 05b757
  /**/
Karsten Hopp 05b757
Karsten Hopp 05b757
-- 
Karsten Hopp 05b757
How To Keep A Healthy Level Of Insanity:
Karsten Hopp 05b757
6. In the memo field of all your checks, write "for sexual favors".
Karsten Hopp 05b757
Karsten Hopp 05b757
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 05b757
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 05b757
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 05b757
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///