Karsten Hopp 2e13ad
To: vim_dev@googlegroups.com
Karsten Hopp 2e13ad
Subject: Patch 7.3.1227
Karsten Hopp 2e13ad
Fcc: outbox
Karsten Hopp 2e13ad
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2e13ad
Mime-Version: 1.0
Karsten Hopp 2e13ad
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2e13ad
Content-Transfer-Encoding: 8bit
Karsten Hopp 2e13ad
------------
Karsten Hopp 2e13ad
Karsten Hopp 2e13ad
Patch 7.3.1227
Karsten Hopp 2e13ad
Problem:    Inconsistent string conversion.
Karsten Hopp 2e13ad
Solution:   Use 'encoding' instead of utf-8. Use METH_O in place of
Karsten Hopp 2e13ad
	    METH_VARARGS where appropriate. (ZyX)
Karsten Hopp 2e13ad
Files:	    src/if_py_both.h, src/testdir/test86.ok, src/testdir/test87.ok
Karsten Hopp 2e13ad
Karsten Hopp 2e13ad
Karsten Hopp 2e13ad
*** ../vim-7.3.1226/src/if_py_both.h	2013-06-23 12:51:27.000000000 +0200
Karsten Hopp 2e13ad
--- src/if_py_both.h	2013-06-23 12:57:34.000000000 +0200
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 466,486 ****
Karsten Hopp 2e13ad
   */
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimCommand(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char *cmd;
Karsten Hopp 2e13ad
!     PyObject *result;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &cmd))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
-     PyErr_Clear();
Karsten Hopp 2e13ad
- 
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     do_cmdline_cmd((char_u *)cmd);
Karsten Hopp 2e13ad
      update_screen(VALID);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
--- 466,485 ----
Karsten Hopp 2e13ad
   */
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimCommand(PyObject *self UNUSED, PyObject *string)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char_u	*cmd;
Karsten Hopp 2e13ad
!     PyObject	*result;
Karsten Hopp 2e13ad
!     PyObject	*todecref;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!(cmd = StringToChars(string, &todecref)))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     do_cmdline_cmd(cmd);
Karsten Hopp 2e13ad
      update_screen(VALID);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 491,498 ****
Karsten Hopp 2e13ad
      else
Karsten Hopp 2e13ad
  	result = Py_None;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
- 
Karsten Hopp 2e13ad
      Py_XINCREF(result);
Karsten Hopp 2e13ad
      return result;
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
--- 490,497 ----
Karsten Hopp 2e13ad
      else
Karsten Hopp 2e13ad
  	result = Py_None;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_XINCREF(result);
Karsten Hopp 2e13ad
+     Py_XDECREF(todecref);
Karsten Hopp 2e13ad
      return result;
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 641,661 ****
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
  VimEval(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char	*expr;
Karsten Hopp 2e13ad
      typval_T	*our_tv;
Karsten Hopp 2e13ad
      PyObject	*result;
Karsten Hopp 2e13ad
!     PyObject    *lookup_dict;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &expr))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
      Py_END_ALLOW_THREADS
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      if (VimTryEnd())
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
--- 640,667 ----
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
  VimEval(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char_u	*expr;
Karsten Hopp 2e13ad
      typval_T	*our_tv;
Karsten Hopp 2e13ad
+     PyObject	*string;
Karsten Hopp 2e13ad
+     PyObject	*todecref;
Karsten Hopp 2e13ad
      PyObject	*result;
Karsten Hopp 2e13ad
!     PyObject	*lookup_dict;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "O", &string))
Karsten Hopp 2e13ad
! 	return NULL;
Karsten Hopp 2e13ad
! 
Karsten Hopp 2e13ad
!     if (!(expr = StringToChars(string, &todecref)))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     our_tv = eval_expr(expr, NULL);
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
      Py_END_ALLOW_THREADS
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
+     Py_XDECREF(todecref);
Karsten Hopp 2e13ad
+ 
Karsten Hopp 2e13ad
      if (VimTryEnd())
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 688,709 ****
Karsten Hopp 2e13ad
  static PyObject *ConvertToPyObject(typval_T *);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimEvalPy(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
-     char	*expr;
Karsten Hopp 2e13ad
      typval_T	*our_tv;
Karsten Hopp 2e13ad
      PyObject	*result;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &expr))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     our_tv = eval_expr((char_u *)expr, NULL);
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
      Py_END_ALLOW_THREADS
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      if (VimTryEnd())
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
--- 694,718 ----
Karsten Hopp 2e13ad
  static PyObject *ConvertToPyObject(typval_T *);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimEvalPy(PyObject *self UNUSED, PyObject *string)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      typval_T	*our_tv;
Karsten Hopp 2e13ad
      PyObject	*result;
Karsten Hopp 2e13ad
+     char_u	*expr;
Karsten Hopp 2e13ad
+     PyObject	*todecref;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!(expr = StringToChars(string, &todecref)))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp 2e13ad
      Python_Lock_Vim();
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
!     our_tv = eval_expr(expr, NULL);
Karsten Hopp 2e13ad
      Python_Release_Vim();
Karsten Hopp 2e13ad
      Py_END_ALLOW_THREADS
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
+     Py_XDECREF(todecref);
Karsten Hopp 2e13ad
+ 
Karsten Hopp 2e13ad
      if (VimTryEnd())
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 724,743 ****
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimStrwidth(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char	*expr;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &expr))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
-     return PyLong_FromLong(
Karsten Hopp 2e13ad
  #ifdef FEAT_MBYTE
Karsten Hopp 2e13ad
! 	    mb_string2cells((char_u *)expr, (int)STRLEN(expr))
Karsten Hopp 2e13ad
  #else
Karsten Hopp 2e13ad
! 	    STRLEN(expr)
Karsten Hopp 2e13ad
  #endif
Karsten Hopp 2e13ad
! 	    );
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
--- 733,756 ----
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimStrwidth(PyObject *self UNUSED, PyObject *string)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
!     char_u	*str;
Karsten Hopp 2e13ad
!     PyObject	*todecref;
Karsten Hopp 2e13ad
!     int		result;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!(str = StringToChars(string, &todecref)))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
  #ifdef FEAT_MBYTE
Karsten Hopp 2e13ad
!     result = mb_string2cells(str, (int)STRLEN(str));
Karsten Hopp 2e13ad
  #else
Karsten Hopp 2e13ad
!     result = STRLEN(str);
Karsten Hopp 2e13ad
  #endif
Karsten Hopp 2e13ad
! 
Karsten Hopp 2e13ad
!     Py_XDECREF(todecref);
Karsten Hopp 2e13ad
! 
Karsten Hopp 2e13ad
!     return PyLong_FromLong(result);
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 840,852 ****
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimForeachRTP(PyObject *self UNUSED, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      map_rtp_data	data;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "O", &data.callable))
Karsten Hopp 2e13ad
! 	return NULL;
Karsten Hopp 2e13ad
! 
Karsten Hopp 2e13ad
      data.result = NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data);
Karsten Hopp 2e13ad
--- 853,863 ----
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! VimForeachRTP(PyObject *self UNUSED, PyObject *callable)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      map_rtp_data	data;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     data.callable = callable;
Karsten Hopp 2e13ad
      data.result = NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data);
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1099,1111 ****
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
  static struct PyMethodDef VimMethods[] = {
Karsten Hopp 2e13ad
      /* name,	    function,			calling,			documentation */
Karsten Hopp 2e13ad
!     {"command",	    VimCommand,			METH_VARARGS,			"Execute a Vim ex-mode command" },
Karsten Hopp 2e13ad
      {"eval",	    VimEval,			METH_VARARGS,			"Evaluate an expression using Vim evaluator" },
Karsten Hopp 2e13ad
!     {"bindeval",    VimEvalPy,			METH_VARARGS,			"Like eval(), but returns objects attached to vim ones"},
Karsten Hopp 2e13ad
!     {"strwidth",    VimStrwidth,		METH_VARARGS,			"Screen string width, counts <Tab> as having width 1"},
Karsten Hopp 2e13ad
      {"chdir",	    (PyCFunction)VimChdir,	METH_VARARGS|METH_KEYWORDS,	"Change directory"},
Karsten Hopp 2e13ad
      {"fchdir",	    (PyCFunction)VimFchdir,	METH_VARARGS|METH_KEYWORDS,	"Change directory"},
Karsten Hopp 2e13ad
!     {"foreach_rtp", VimForeachRTP,		METH_VARARGS,			"Call given callable for each path in &rtp"},
Karsten Hopp 2e13ad
      {"find_module", FinderFindModule,		METH_VARARGS,			"Internal use only, returns loader object for any input it receives"},
Karsten Hopp 2e13ad
      {"path_hook",   VimPathHook,		METH_VARARGS,			"Hook function to install in sys.path_hooks"},
Karsten Hopp 2e13ad
      {"_get_paths",  (PyCFunction)Vim_GetPaths,	METH_NOARGS,			"Get &rtp-based additions to sys.path"},
Karsten Hopp 2e13ad
--- 1110,1122 ----
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
  static struct PyMethodDef VimMethods[] = {
Karsten Hopp 2e13ad
      /* name,	    function,			calling,			documentation */
Karsten Hopp 2e13ad
!     {"command",	    VimCommand,			METH_O,				"Execute a Vim ex-mode command" },
Karsten Hopp 2e13ad
      {"eval",	    VimEval,			METH_VARARGS,			"Evaluate an expression using Vim evaluator" },
Karsten Hopp 2e13ad
!     {"bindeval",    VimEvalPy,			METH_O,				"Like eval(), but returns objects attached to vim ones"},
Karsten Hopp 2e13ad
!     {"strwidth",    VimStrwidth,		METH_O,				"Screen string width, counts <Tab> as having width 1"},
Karsten Hopp 2e13ad
      {"chdir",	    (PyCFunction)VimChdir,	METH_VARARGS|METH_KEYWORDS,	"Change directory"},
Karsten Hopp 2e13ad
      {"fchdir",	    (PyCFunction)VimFchdir,	METH_VARARGS|METH_KEYWORDS,	"Change directory"},
Karsten Hopp 2e13ad
!     {"foreach_rtp", VimForeachRTP,		METH_O,				"Call given callable for each path in &rtp"},
Karsten Hopp 2e13ad
      {"find_module", FinderFindModule,		METH_VARARGS,			"Internal use only, returns loader object for any input it receives"},
Karsten Hopp 2e13ad
      {"path_hook",   VimPathHook,		METH_VARARGS,			"Hook function to install in sys.path_hooks"},
Karsten Hopp 2e13ad
      {"_get_paths",  (PyCFunction)Vim_GetPaths,	METH_NOARGS,			"Get &rtp-based additions to sys.path"},
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1733,1739 ****
Karsten Hopp 2e13ad
      {
Karsten Hopp 2e13ad
  	PyObject	*object;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
! 	if (!PyArg_Parse(args, "(O)", &object))
Karsten Hopp 2e13ad
  	    return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
  	if (PyObject_HasAttrString(object, "keys"))
Karsten Hopp 2e13ad
--- 1744,1750 ----
Karsten Hopp 2e13ad
      {
Karsten Hopp 2e13ad
  	PyObject	*object;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
! 	if (!PyArg_ParseTuple(args, "O", &object))
Karsten Hopp 2e13ad
  	    return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
  	if (PyObject_HasAttrString(object, "keys"))
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1877,1889 ****
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! DictionaryHasKey(DictionaryObject *self, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
-     PyObject	*keyObject;
Karsten Hopp 2e13ad
- 
Karsten Hopp 2e13ad
-     if (!PyArg_ParseTuple(args, "O", &keyObject))
Karsten Hopp 2e13ad
- 	return NULL;
Karsten Hopp 2e13ad
- 
Karsten Hopp 2e13ad
      return _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
--- 1888,1895 ----
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! DictionaryHasKey(DictionaryObject *self, PyObject *keyObject)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      return _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1914,1920 ****
Karsten Hopp 2e13ad
      {"get",	(PyCFunction)DictionaryGet,		METH_VARARGS,	""},
Karsten Hopp 2e13ad
      {"pop",	(PyCFunction)DictionaryPop,		METH_VARARGS,	""},
Karsten Hopp 2e13ad
      {"popitem",	(PyCFunction)DictionaryPopItem,		METH_NOARGS,	""},
Karsten Hopp 2e13ad
!     {"has_key",	(PyCFunction)DictionaryHasKey,		METH_VARARGS,	""},
Karsten Hopp 2e13ad
      {"__dir__",	(PyCFunction)DictionaryDir,		METH_NOARGS,	""},
Karsten Hopp 2e13ad
      { NULL,	NULL,					0,		NULL}
Karsten Hopp 2e13ad
  };
Karsten Hopp 2e13ad
--- 1920,1926 ----
Karsten Hopp 2e13ad
      {"get",	(PyCFunction)DictionaryGet,		METH_VARARGS,	""},
Karsten Hopp 2e13ad
      {"pop",	(PyCFunction)DictionaryPop,		METH_VARARGS,	""},
Karsten Hopp 2e13ad
      {"popitem",	(PyCFunction)DictionaryPopItem,		METH_NOARGS,	""},
Karsten Hopp 2e13ad
!     {"has_key",	(PyCFunction)DictionaryHasKey,		METH_O,		""},
Karsten Hopp 2e13ad
      {"__dir__",	(PyCFunction)DictionaryDir,		METH_NOARGS,	""},
Karsten Hopp 2e13ad
      { NULL,	NULL,					0,		NULL}
Karsten Hopp 2e13ad
  };
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 2434,2444 ****
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
      }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &name))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      self = FunctionNew(subtype, name);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      return self;
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
--- 2440,2452 ----
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
      }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "et", "ascii", &name))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      self = FunctionNew(subtype, name);
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
+     PyMem_Free(name);
Karsten Hopp 2e13ad
+ 
Karsten Hopp 2e13ad
      return self;
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 4383,4402 ****
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! BufferMark(BufferObject *self, PyObject *args)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      pos_T	*posp;
Karsten Hopp 2e13ad
!     char	*pmark;
Karsten Hopp 2e13ad
!     char	mark;
Karsten Hopp 2e13ad
      buf_T	*savebuf;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      if (CheckBuffer(self))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!PyArg_ParseTuple(args, "s", &pmark))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (STRLEN(pmark) != 1)
Karsten Hopp 2e13ad
      {
Karsten Hopp 2e13ad
  	PyErr_SetString(PyExc_ValueError,
Karsten Hopp 2e13ad
  		_("mark name must be a single character"));
Karsten Hopp 2e13ad
--- 4391,4411 ----
Karsten Hopp 2e13ad
  }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      static PyObject *
Karsten Hopp 2e13ad
! BufferMark(BufferObject *self, PyObject *pmarkObject)
Karsten Hopp 2e13ad
  {
Karsten Hopp 2e13ad
      pos_T	*posp;
Karsten Hopp 2e13ad
!     char_u	*pmark;
Karsten Hopp 2e13ad
!     char_u	mark;
Karsten Hopp 2e13ad
      buf_T	*savebuf;
Karsten Hopp 2e13ad
+     PyObject	*todecref;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      if (CheckBuffer(self))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (!(pmark = StringToChars(pmarkObject, &todecref)))
Karsten Hopp 2e13ad
  	return NULL;
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
!     if (pmark[0] == '\0' || pmark[1] != '\0')
Karsten Hopp 2e13ad
      {
Karsten Hopp 2e13ad
  	PyErr_SetString(PyExc_ValueError,
Karsten Hopp 2e13ad
  		_("mark name must be a single character"));
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 4404,4409 ****
Karsten Hopp 2e13ad
--- 4413,4421 ----
Karsten Hopp 2e13ad
      }
Karsten Hopp 2e13ad
  
Karsten Hopp 2e13ad
      mark = *pmark;
Karsten Hopp 2e13ad
+ 
Karsten Hopp 2e13ad
+     Py_XDECREF(todecref);
Karsten Hopp 2e13ad
+ 
Karsten Hopp 2e13ad
      VimTryStart();
Karsten Hopp 2e13ad
      switch_buffer(&savebuf, self->buf);
Karsten Hopp 2e13ad
      posp = getmark(mark, FALSE);
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 4461,4467 ****
Karsten Hopp 2e13ad
  static struct PyMethodDef BufferMethods[] = {
Karsten Hopp 2e13ad
      /* name,	    function,			calling,	documentation */
Karsten Hopp 2e13ad
      {"append",	    (PyCFunction)BufferAppend,	METH_VARARGS,	"Append data to Vim buffer" },
Karsten Hopp 2e13ad
!     {"mark",	    (PyCFunction)BufferMark,	METH_VARARGS,	"Return (row,col) representing position of named mark" },
Karsten Hopp 2e13ad
      {"range",	    (PyCFunction)BufferRange,	METH_VARARGS,	"Return a range object which represents the part of the given buffer between line numbers s and e" },
Karsten Hopp 2e13ad
      {"__dir__",	    (PyCFunction)BufferDir,	METH_NOARGS,	""},
Karsten Hopp 2e13ad
      { NULL,	    NULL,			0,		NULL}
Karsten Hopp 2e13ad
--- 4473,4479 ----
Karsten Hopp 2e13ad
  static struct PyMethodDef BufferMethods[] = {
Karsten Hopp 2e13ad
      /* name,	    function,			calling,	documentation */
Karsten Hopp 2e13ad
      {"append",	    (PyCFunction)BufferAppend,	METH_VARARGS,	"Append data to Vim buffer" },
Karsten Hopp 2e13ad
!     {"mark",	    (PyCFunction)BufferMark,	METH_O,		"Return (row,col) representing position of named mark" },
Karsten Hopp 2e13ad
      {"range",	    (PyCFunction)BufferRange,	METH_VARARGS,	"Return a range object which represents the part of the given buffer between line numbers s and e" },
Karsten Hopp 2e13ad
      {"__dir__",	    (PyCFunction)BufferDir,	METH_NOARGS,	""},
Karsten Hopp 2e13ad
      { NULL,	    NULL,			0,		NULL}
Karsten Hopp 2e13ad
*** ../vim-7.3.1226/src/testdir/test86.ok	2013-06-23 12:51:27.000000000 +0200
Karsten Hopp 2e13ad
--- src/testdir/test86.ok	2013-06-23 12:57:34.000000000 +0200
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 446,459 ****
Karsten Hopp 2e13ad
  sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",)
Karsten Hopp 2e13ad
  sys.stdout.writelines([1]):TypeError:('coercing to Unicode: need string or buffer, int found',)
Karsten Hopp 2e13ad
  > VimCommand
Karsten Hopp 2e13ad
! vim.command(1):TypeError:('must be string, not int',)
Karsten Hopp 2e13ad
  > VimToPython
Karsten Hopp 2e13ad
  > VimEval
Karsten Hopp 2e13ad
! vim.eval(1):TypeError:('must be string, not int',)
Karsten Hopp 2e13ad
  > VimEvalPy
Karsten Hopp 2e13ad
! vim.bindeval(1):TypeError:('must be string, not int',)
Karsten Hopp 2e13ad
  > VimStrwidth
Karsten Hopp 2e13ad
! vim.strwidth(1):TypeError:('must be string, not int',)
Karsten Hopp 2e13ad
  > Dictionary
Karsten Hopp 2e13ad
  >> DictionaryConstructor
Karsten Hopp 2e13ad
  vim.Dictionary("abc"):ValueError:('expected sequence element of size 2',)
Karsten Hopp 2e13ad
--- 446,459 ----
Karsten Hopp 2e13ad
  sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",)
Karsten Hopp 2e13ad
  sys.stdout.writelines([1]):TypeError:('coercing to Unicode: need string or buffer, int found',)
Karsten Hopp 2e13ad
  > VimCommand
Karsten Hopp 2e13ad
! vim.command(1):TypeError:('object must be string',)
Karsten Hopp 2e13ad
  > VimToPython
Karsten Hopp 2e13ad
  > VimEval
Karsten Hopp 2e13ad
! vim.eval(1):TypeError:('object must be string',)
Karsten Hopp 2e13ad
  > VimEvalPy
Karsten Hopp 2e13ad
! vim.bindeval(1):TypeError:('object must be string',)
Karsten Hopp 2e13ad
  > VimStrwidth
Karsten Hopp 2e13ad
! vim.strwidth(1):TypeError:('object must be string',)
Karsten Hopp 2e13ad
  > Dictionary
Karsten Hopp 2e13ad
  >> DictionaryConstructor
Karsten Hopp 2e13ad
  vim.Dictionary("abc"):ValueError:('expected sequence element of size 2',)
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 683,689 ****
Karsten Hopp 2e13ad
  >> DictionaryPopItem
Karsten Hopp 2e13ad
  d.popitem(1, 2):TypeError:('popitem() takes no arguments (2 given)',)
Karsten Hopp 2e13ad
  >> DictionaryHasKey
Karsten Hopp 2e13ad
! d.has_key():TypeError:('function takes exactly 1 argument (0 given)',)
Karsten Hopp 2e13ad
  > List
Karsten Hopp 2e13ad
  >> ListConstructor
Karsten Hopp 2e13ad
  vim.List(1, 2):TypeError:('function takes at most 1 argument (2 given)',)
Karsten Hopp 2e13ad
--- 683,689 ----
Karsten Hopp 2e13ad
  >> DictionaryPopItem
Karsten Hopp 2e13ad
  d.popitem(1, 2):TypeError:('popitem() takes no arguments (2 given)',)
Karsten Hopp 2e13ad
  >> DictionaryHasKey
Karsten Hopp 2e13ad
! d.has_key():TypeError:('has_key() takes exactly one argument (0 given)',)
Karsten Hopp 2e13ad
  > List
Karsten Hopp 2e13ad
  >> ListConstructor
Karsten Hopp 2e13ad
  vim.List(1, 2):TypeError:('function takes at most 1 argument (2 given)',)
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1065,1071 ****
Karsten Hopp 2e13ad
  vim.current.buffer.name = True:TypeError:('object must be string',)
Karsten Hopp 2e13ad
  vim.current.buffer.xxx = True:AttributeError:('xxx',)
Karsten Hopp 2e13ad
  >> BufferMark
Karsten Hopp 2e13ad
! vim.current.buffer.mark(0):TypeError:('must be string, not int',)
Karsten Hopp 2e13ad
  vim.current.buffer.mark("abc"):ValueError:('mark name must be a single character',)
Karsten Hopp 2e13ad
  vim.current.buffer.mark("!"):error:('invalid mark name',)
Karsten Hopp 2e13ad
  >> BufferRange
Karsten Hopp 2e13ad
--- 1065,1071 ----
Karsten Hopp 2e13ad
  vim.current.buffer.name = True:TypeError:('object must be string',)
Karsten Hopp 2e13ad
  vim.current.buffer.xxx = True:AttributeError:('xxx',)
Karsten Hopp 2e13ad
  >> BufferMark
Karsten Hopp 2e13ad
! vim.current.buffer.mark(0):TypeError:('object must be string',)
Karsten Hopp 2e13ad
  vim.current.buffer.mark("abc"):ValueError:('mark name must be a single character',)
Karsten Hopp 2e13ad
  vim.current.buffer.mark("!"):error:('invalid mark name',)
Karsten Hopp 2e13ad
  >> BufferRange
Karsten Hopp 2e13ad
*** ../vim-7.3.1226/src/testdir/test87.ok	2013-06-23 12:51:27.000000000 +0200
Karsten Hopp 2e13ad
--- src/testdir/test87.ok	2013-06-23 12:57:34.000000000 +0200
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 439,452 ****
Karsten Hopp 2e13ad
  sys.stdout.writelines(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError())
Karsten Hopp 2e13ad
  <<< Finished
Karsten Hopp 2e13ad
  > VimCommand
Karsten Hopp 2e13ad
! vim.command(1):(<class 'TypeError'>, TypeError('must be str, not int',))
Karsten Hopp 2e13ad
  > VimToPython
Karsten Hopp 2e13ad
  > VimEval
Karsten Hopp 2e13ad
! vim.eval(1):(<class 'TypeError'>, TypeError('must be str, not int',))
Karsten Hopp 2e13ad
  > VimEvalPy
Karsten Hopp 2e13ad
! vim.bindeval(1):(<class 'TypeError'>, TypeError('must be str, not int',))
Karsten Hopp 2e13ad
  > VimStrwidth
Karsten Hopp 2e13ad
! vim.strwidth(1):(<class 'TypeError'>, TypeError('must be str, not int',))
Karsten Hopp 2e13ad
  > Dictionary
Karsten Hopp 2e13ad
  >> DictionaryConstructor
Karsten Hopp 2e13ad
  vim.Dictionary("abc"):(<class 'ValueError'>, ValueError('expected sequence element of size 2',))
Karsten Hopp 2e13ad
--- 439,452 ----
Karsten Hopp 2e13ad
  sys.stdout.writelines(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError())
Karsten Hopp 2e13ad
  <<< Finished
Karsten Hopp 2e13ad
  > VimCommand
Karsten Hopp 2e13ad
! vim.command(1):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  > VimToPython
Karsten Hopp 2e13ad
  > VimEval
Karsten Hopp 2e13ad
! vim.eval(1):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  > VimEvalPy
Karsten Hopp 2e13ad
! vim.bindeval(1):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  > VimStrwidth
Karsten Hopp 2e13ad
! vim.strwidth(1):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  > Dictionary
Karsten Hopp 2e13ad
  >> DictionaryConstructor
Karsten Hopp 2e13ad
  vim.Dictionary("abc"):(<class 'ValueError'>, ValueError('expected sequence element of size 2',))
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 680,686 ****
Karsten Hopp 2e13ad
  >> DictionaryPopItem
Karsten Hopp 2e13ad
  d.popitem(1, 2):(<class 'TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
Karsten Hopp 2e13ad
  >> DictionaryHasKey
Karsten Hopp 2e13ad
! d.has_key():(<class 'TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
Karsten Hopp 2e13ad
  > List
Karsten Hopp 2e13ad
  >> ListConstructor
Karsten Hopp 2e13ad
  vim.List(1, 2):(<class 'TypeError'>, TypeError('function takes at most 1 argument (2 given)',))
Karsten Hopp 2e13ad
--- 680,686 ----
Karsten Hopp 2e13ad
  >> DictionaryPopItem
Karsten Hopp 2e13ad
  d.popitem(1, 2):(<class 'TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
Karsten Hopp 2e13ad
  >> DictionaryHasKey
Karsten Hopp 2e13ad
! d.has_key():(<class 'TypeError'>, TypeError('has_key() takes exactly one argument (0 given)',))
Karsten Hopp 2e13ad
  > List
Karsten Hopp 2e13ad
  >> ListConstructor
Karsten Hopp 2e13ad
  vim.List(1, 2):(<class 'TypeError'>, TypeError('function takes at most 1 argument (2 given)',))
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 1074,1080 ****
Karsten Hopp 2e13ad
  vim.current.buffer.name = True:(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  vim.current.buffer.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',))
Karsten Hopp 2e13ad
  >> BufferMark
Karsten Hopp 2e13ad
! vim.current.buffer.mark(0):(<class 'TypeError'>, TypeError('must be str, not int',))
Karsten Hopp 2e13ad
  vim.current.buffer.mark("abc"):(<class 'ValueError'>, ValueError('mark name must be a single character',))
Karsten Hopp 2e13ad
  vim.current.buffer.mark("!"):(<class 'vim.error'>, error('invalid mark name',))
Karsten Hopp 2e13ad
  >> BufferRange
Karsten Hopp 2e13ad
--- 1074,1080 ----
Karsten Hopp 2e13ad
  vim.current.buffer.name = True:(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  vim.current.buffer.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',))
Karsten Hopp 2e13ad
  >> BufferMark
Karsten Hopp 2e13ad
! vim.current.buffer.mark(0):(<class 'TypeError'>, TypeError('object must be string',))
Karsten Hopp 2e13ad
  vim.current.buffer.mark("abc"):(<class 'ValueError'>, ValueError('mark name must be a single character',))
Karsten Hopp 2e13ad
  vim.current.buffer.mark("!"):(<class 'vim.error'>, error('invalid mark name',))
Karsten Hopp 2e13ad
  >> BufferRange
Karsten Hopp 2e13ad
*** ../vim-7.3.1226/src/version.c	2013-06-23 12:51:27.000000000 +0200
Karsten Hopp 2e13ad
--- src/version.c	2013-06-23 12:56:45.000000000 +0200
Karsten Hopp 2e13ad
***************
Karsten Hopp 2e13ad
*** 730,731 ****
Karsten Hopp 2e13ad
--- 730,733 ----
Karsten Hopp 2e13ad
  {   /* Add new patch number below this line */
Karsten Hopp 2e13ad
+ /**/
Karsten Hopp 2e13ad
+     1227,
Karsten Hopp 2e13ad
  /**/
Karsten Hopp 2e13ad
Karsten Hopp 2e13ad
-- 
Karsten Hopp 2e13ad
       We're knights of the Round Table
Karsten Hopp 2e13ad
       Our shows are formidable
Karsten Hopp 2e13ad
       But many times
Karsten Hopp 2e13ad
       We're given rhymes
Karsten Hopp 2e13ad
       That are quite unsingable
Karsten Hopp 2e13ad
       We're opera mad in Camelot
Karsten Hopp 2e13ad
       We sing from the diaphragm a lot.
Karsten Hopp 2e13ad
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 2e13ad
Karsten Hopp 2e13ad
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2e13ad
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2e13ad
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2e13ad
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///