Karsten Hopp f490c9
To: vim_dev@googlegroups.com
Karsten Hopp f490c9
Subject: Patch 7.3.1060
Karsten Hopp f490c9
Fcc: outbox
Karsten Hopp f490c9
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f490c9
Mime-Version: 1.0
Karsten Hopp f490c9
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f490c9
Content-Transfer-Encoding: 8bit
Karsten Hopp f490c9
------------
Karsten Hopp f490c9
Karsten Hopp f490c9
Patch 7.3.1060
Karsten Hopp f490c9
Problem:    Python: can't repr() a function.
Karsten Hopp f490c9
Solution:   Python patch 19: add FunctionRepr(). (ZyX)
Karsten Hopp f490c9
Files:	    src/if_py_both.h
Karsten Hopp f490c9
Karsten Hopp f490c9
Karsten Hopp f490c9
*** ../vim-7.3.1059/src/if_py_both.h	2013-05-30 12:40:36.000000000 +0200
Karsten Hopp f490c9
--- src/if_py_both.h	2013-05-30 12:43:16.000000000 +0200
Karsten Hopp f490c9
***************
Karsten Hopp f490c9
*** 1584,1589 ****
Karsten Hopp f490c9
--- 1584,1595 ----
Karsten Hopp f490c9
      return result;
Karsten Hopp f490c9
  }
Karsten Hopp f490c9
  
Karsten Hopp f490c9
+     static PyObject *
Karsten Hopp f490c9
+ FunctionRepr(FunctionObject *self)
Karsten Hopp f490c9
+ {
Karsten Hopp f490c9
+     return PyString_FromFormat("<vim.Function '%s'>", self->name);
Karsten Hopp f490c9
+ }
Karsten Hopp f490c9
+ 
Karsten Hopp f490c9
  static struct PyMethodDef FunctionMethods[] = {
Karsten Hopp f490c9
      {"__call__",(PyCFunction)FunctionCall,  METH_VARARGS|METH_KEYWORDS,	""},
Karsten Hopp f490c9
      {"__dir__",	(PyCFunction)FunctionDir,   METH_NOARGS,		""},
Karsten Hopp f490c9
***************
Karsten Hopp f490c9
*** 4640,4645 ****
Karsten Hopp f490c9
--- 4646,4652 ----
Karsten Hopp f490c9
      FunctionType.tp_flags = Py_TPFLAGS_DEFAULT;
Karsten Hopp f490c9
      FunctionType.tp_doc = "object that calls vim function";
Karsten Hopp f490c9
      FunctionType.tp_methods = FunctionMethods;
Karsten Hopp f490c9
+     FunctionType.tp_repr = (reprfunc)FunctionRepr;
Karsten Hopp f490c9
  #if PY_MAJOR_VERSION >= 3
Karsten Hopp f490c9
      FunctionType.tp_getattro = (getattrofunc)FunctionGetattro;
Karsten Hopp f490c9
  #else
Karsten Hopp f490c9
*** ../vim-7.3.1059/src/version.c	2013-05-30 12:40:36.000000000 +0200
Karsten Hopp f490c9
--- src/version.c	2013-05-30 12:43:06.000000000 +0200
Karsten Hopp f490c9
***************
Karsten Hopp f490c9
*** 730,731 ****
Karsten Hopp f490c9
--- 730,733 ----
Karsten Hopp f490c9
  {   /* Add new patch number below this line */
Karsten Hopp f490c9
+ /**/
Karsten Hopp f490c9
+     1060,
Karsten Hopp f490c9
  /**/
Karsten Hopp f490c9
Karsten Hopp f490c9
-- 
Karsten Hopp f490c9
How To Keep A Healthy Level Of Insanity:
Karsten Hopp f490c9
3. Every time someone asks you to do something, ask if they want fries
Karsten Hopp f490c9
   with that.
Karsten Hopp f490c9
Karsten Hopp f490c9
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f490c9
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f490c9
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f490c9
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///