Karsten Hopp bc8f74
To: vim_dev@googlegroups.com
Karsten Hopp bc8f74
Subject: Patch 7.3.1232
Karsten Hopp bc8f74
Fcc: outbox
Karsten Hopp bc8f74
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bc8f74
Mime-Version: 1.0
Karsten Hopp bc8f74
Content-Type: text/plain; charset=UTF-8
Karsten Hopp bc8f74
Content-Transfer-Encoding: 8bit
Karsten Hopp bc8f74
------------
Karsten Hopp bc8f74
Karsten Hopp bc8f74
Patch 7.3.1232
Karsten Hopp bc8f74
Problem:    Python: inconsistencies in variable names.
Karsten Hopp bc8f74
Solution:   Rename variables. (ZyX)
Karsten Hopp bc8f74
Files:	    src/eval.c, src/if_py_both.h
Karsten Hopp bc8f74
Karsten Hopp bc8f74
Karsten Hopp bc8f74
*** ../vim-7.3.1231/src/eval.c	2013-06-16 17:32:33.000000000 +0200
Karsten Hopp bc8f74
--- src/eval.c	2013-06-23 14:29:13.000000000 +0200
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3228,3234 ****
Karsten Hopp bc8f74
      void	*fi_void;
Karsten Hopp bc8f74
      char_u	*arg;
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     forinfo_T    *fi = (forinfo_T *)fi_void;
Karsten Hopp bc8f74
      int		result;
Karsten Hopp bc8f74
      listitem_T	*item;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 3228,3234 ----
Karsten Hopp bc8f74
      void	*fi_void;
Karsten Hopp bc8f74
      char_u	*arg;
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     forinfo_T	*fi = (forinfo_T *)fi_void;
Karsten Hopp bc8f74
      int		result;
Karsten Hopp bc8f74
      listitem_T	*item;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
*** ../vim-7.3.1231/src/if_py_both.h	2013-06-23 14:16:53.000000000 +0200
Karsten Hopp bc8f74
--- src/if_py_both.h	2013-06-23 14:29:13.000000000 +0200
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 107,134 ****
Karsten Hopp bc8f74
   * Use Py_XDECREF to decrement reference count.
Karsten Hopp bc8f74
   */
Karsten Hopp bc8f74
      static char_u *
Karsten Hopp bc8f74
! StringToChars(PyObject *object, PyObject **todecref)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     char_u	*p;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (PyBytes_Check(object))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyBytes_AsStringAndSize(object, (char **) &p, NULL) == -1
Karsten Hopp bc8f74
! 		|| p == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	*todecref = NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     else if (PyUnicode_Check(object))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyObject	*bytes;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(bytes = PyUnicode_AsEncodedString(object, ENC_OPT, NULL)))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if(PyBytes_AsStringAndSize(bytes, (char **) &p, NULL) == -1
Karsten Hopp bc8f74
! 		|| p == NULL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_DECREF(bytes);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
--- 107,134 ----
Karsten Hopp bc8f74
   * Use Py_XDECREF to decrement reference count.
Karsten Hopp bc8f74
   */
Karsten Hopp bc8f74
      static char_u *
Karsten Hopp bc8f74
! StringToChars(PyObject *obj, PyObject **todecref)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     char_u	*str;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (PyBytes_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyBytes_AsStringAndSize(obj, (char **) &str, NULL) == -1
Karsten Hopp bc8f74
! 		|| str == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	*todecref = NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     else if (PyUnicode_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyObject	*bytes;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if(PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1
Karsten Hopp bc8f74
! 		|| str == NULL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_DECREF(bytes);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 144,154 ****
Karsten Hopp bc8f74
  #else
Karsten Hopp bc8f74
  		"expected bytes() or str() instance, but got %s"
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
! 		, Py_TYPE_NAME(object));
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return (char_u *) p;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #define NUMBER_LONG     1
Karsten Hopp bc8f74
--- 144,154 ----
Karsten Hopp bc8f74
  #else
Karsten Hopp bc8f74
  		"expected bytes() or str() instance, but got %s"
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
! 		, Py_TYPE_NAME(obj));
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return (char_u *) str;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #define NUMBER_LONG     1
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 263,297 ****
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyMethodDef	*method;
Karsten Hopp bc8f74
      char	**attr;
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = PyList_New(0)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (self)
Karsten Hopp bc8f74
  	for (method = self->ob_type->tp_methods ; method->ml_name != NULL ; ++method)
Karsten Hopp bc8f74
! 	    if (add_string(r, (char *) method->ml_name))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(r);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (attr = attributes ; *attr ; ++attr)
Karsten Hopp bc8f74
! 	if (add_string(r, *attr))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(r);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #if PY_MAJOR_VERSION < 3
Karsten Hopp bc8f74
!     if (add_string(r, "__members__"))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  /* Output buffer management
Karsten Hopp bc8f74
--- 263,297 ----
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyMethodDef	*method;
Karsten Hopp bc8f74
      char	**attr;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = PyList_New(0)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (self)
Karsten Hopp bc8f74
  	for (method = self->ob_type->tp_methods ; method->ml_name != NULL ; ++method)
Karsten Hopp bc8f74
! 	    if (add_string(ret, (char *) method->ml_name))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(ret);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (attr = attributes ; *attr ; ++attr)
Karsten Hopp bc8f74
! 	if (add_string(ret, *attr))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(ret);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #if PY_MAJOR_VERSION < 3
Karsten Hopp bc8f74
!     if (add_string(ret, "__members__"))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  /* Output buffer management
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 321,329 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! OutputSetattr(OutputObject *self, char *name, PyObject *val)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (val == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"can't delete OutputObject attributes");
Karsten Hopp bc8f74
--- 321,329 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! OutputSetattr(OutputObject *self, char *name, PyObject *valObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (valObject == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"can't delete OutputObject attributes");
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 332,338 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "softspace") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (NumberToLong(val, &(self->softspace), NUMBER_UNSIGNED))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	return 0;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
--- 332,338 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "softspace") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (NumberToLong(valObject, &(self->softspace), NUMBER_UNSIGNED))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	return 0;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 518,527 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  LoaderLoadModule(LoaderObject *self, PyObject *args UNUSED)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r = self->module;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     Py_INCREF(r);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct PyMethodDef LoaderMethods[] = {
Karsten Hopp bc8f74
--- 518,527 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  LoaderLoadModule(LoaderObject *self, PyObject *args UNUSED)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret = self->module;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     Py_INCREF(ret);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct PyMethodDef LoaderMethods[] = {
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 579,585 ****
Karsten Hopp bc8f74
  VimCommand(PyObject *self UNUSED, PyObject *string)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      char_u	*cmd;
Karsten Hopp bc8f74
!     PyObject	*result;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(cmd = StringToChars(string, &todecref)))
Karsten Hopp bc8f74
--- 579,585 ----
Karsten Hopp bc8f74
  VimCommand(PyObject *self UNUSED, PyObject *string)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      char_u	*cmd;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(cmd = StringToChars(string, &todecref)))
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 596,608 ****
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
! 	result = NULL;
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
! 	result = Py_None;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     Py_XINCREF(result);
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
!     return result;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  /*
Karsten Hopp bc8f74
--- 596,608 ----
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
! 	ret = NULL;
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
! 	ret = Py_None;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     Py_XINCREF(ret);
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  /*
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 615,621 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*result;
Karsten Hopp bc8f74
      PyObject	*newObj;
Karsten Hopp bc8f74
      char	ptrBuf[sizeof(void *) * 2 + 3];
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 615,621 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      PyObject	*newObj;
Karsten Hopp bc8f74
      char	ptrBuf[sizeof(void *) * 2 + 3];
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 623,630 ****
Karsten Hopp bc8f74
      if (depth > 100)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_INCREF(Py_None);
Karsten Hopp bc8f74
! 	result = Py_None;
Karsten Hopp bc8f74
! 	return result;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      /* Check if we run into a recursive loop.  The item must be in lookup_dict
Karsten Hopp bc8f74
--- 623,630 ----
Karsten Hopp bc8f74
      if (depth > 100)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_INCREF(Py_None);
Karsten Hopp bc8f74
! 	ret = Py_None;
Karsten Hopp bc8f74
! 	return ret;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      /* Check if we run into a recursive loop.  The item must be in lookup_dict
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 636,650 ****
Karsten Hopp bc8f74
  		our_tv->v_type == VAR_LIST ? (void *)our_tv->vval.v_list
Karsten Hopp bc8f74
  					   : (void *)our_tv->vval.v_dict);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if ((result = PyDict_GetItemString(lookup_dict, ptrBuf)))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_INCREF(result);
Karsten Hopp bc8f74
! 	    return result;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (our_tv->v_type == VAR_STRING)
Karsten Hopp bc8f74
! 	result = PyString_FromString(our_tv->vval.v_string == NULL
Karsten Hopp bc8f74
  					? "" : (char *)our_tv->vval.v_string);
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_NUMBER)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
--- 636,650 ----
Karsten Hopp bc8f74
  		our_tv->v_type == VAR_LIST ? (void *)our_tv->vval.v_list
Karsten Hopp bc8f74
  					   : (void *)our_tv->vval.v_dict);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if ((ret = PyDict_GetItemString(lookup_dict, ptrBuf)))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_INCREF(ret);
Karsten Hopp bc8f74
! 	    return ret;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (our_tv->v_type == VAR_STRING)
Karsten Hopp bc8f74
! 	ret = PyString_FromString(our_tv->vval.v_string == NULL
Karsten Hopp bc8f74
  					? "" : (char *)our_tv->vval.v_string);
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_NUMBER)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 652,658 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	/* For backwards compatibility numbers are stored as strings. */
Karsten Hopp bc8f74
  	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
Karsten Hopp bc8f74
! 	result = PyString_FromString((char *) buf);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  # ifdef FEAT_FLOAT
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_FLOAT)
Karsten Hopp bc8f74
--- 652,658 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	/* For backwards compatibility numbers are stored as strings. */
Karsten Hopp bc8f74
  	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
Karsten Hopp bc8f74
! 	ret = PyString_FromString((char *) buf);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  # ifdef FEAT_FLOAT
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_FLOAT)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 660,666 ****
Karsten Hopp bc8f74
  	char buf[NUMBUFLEN];
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	sprintf(buf, "%f", our_tv->vval.v_float);
Karsten Hopp bc8f74
! 	result = PyString_FromString((char *) buf);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  # endif
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_LIST)
Karsten Hopp bc8f74
--- 660,666 ----
Karsten Hopp bc8f74
  	char buf[NUMBUFLEN];
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	sprintf(buf, "%f", our_tv->vval.v_float);
Karsten Hopp bc8f74
! 	ret = PyString_FromString((char *) buf);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  # endif
Karsten Hopp bc8f74
      else if (our_tv->v_type == VAR_LIST)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 671,682 ****
Karsten Hopp bc8f74
  	if (list == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(result = PyList_New(0)))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyDict_SetItemString(lookup_dict, ptrBuf, result))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(result);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 671,682 ----
Karsten Hopp bc8f74
  	if (list == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(ret = PyList_New(0)))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyDict_SetItemString(lookup_dict, ptrBuf, ret))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(ret);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 684,696 ****
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (!(newObj = VimToPython(&curr->li_tv, depth + 1, lookup_dict)))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(result);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    if (PyList_Append(result, newObj))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
  		Py_DECREF(newObj);
Karsten Hopp bc8f74
! 		Py_DECREF(result);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
  	    Py_DECREF(newObj);
Karsten Hopp bc8f74
--- 684,696 ----
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (!(newObj = VimToPython(&curr->li_tv, depth + 1, lookup_dict)))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(ret);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    if (PyList_Append(ret, newObj))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
  		Py_DECREF(newObj);
Karsten Hopp bc8f74
! 		Py_DECREF(ret);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
  	    Py_DECREF(newObj);
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 706,717 ****
Karsten Hopp bc8f74
  	if (our_tv->vval.v_dict == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(result = PyDict_New()))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyDict_SetItemString(lookup_dict, ptrBuf, result))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(result);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 706,717 ----
Karsten Hopp bc8f74
  	if (our_tv->vval.v_dict == NULL)
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!(ret = PyDict_New()))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyDict_SetItemString(lookup_dict, ptrBuf, ret))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    Py_DECREF(ret);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 724,735 ****
Karsten Hopp bc8f74
  		di = dict_lookup(hi);
Karsten Hopp bc8f74
  		if (!(newObj = VimToPython(&di->di_tv, depth + 1, lookup_dict)))
Karsten Hopp bc8f74
  		{
Karsten Hopp bc8f74
! 		    Py_DECREF(result);
Karsten Hopp bc8f74
  		    return NULL;
Karsten Hopp bc8f74
  		}
Karsten Hopp bc8f74
! 		if (PyDict_SetItemString(result, (char *)hi->hi_key, newObj))
Karsten Hopp bc8f74
  		{
Karsten Hopp bc8f74
! 		    Py_DECREF(result);
Karsten Hopp bc8f74
  		    Py_DECREF(newObj);
Karsten Hopp bc8f74
  		    return NULL;
Karsten Hopp bc8f74
  		}
Karsten Hopp bc8f74
--- 724,735 ----
Karsten Hopp bc8f74
  		di = dict_lookup(hi);
Karsten Hopp bc8f74
  		if (!(newObj = VimToPython(&di->di_tv, depth + 1, lookup_dict)))
Karsten Hopp bc8f74
  		{
Karsten Hopp bc8f74
! 		    Py_DECREF(ret);
Karsten Hopp bc8f74
  		    return NULL;
Karsten Hopp bc8f74
  		}
Karsten Hopp bc8f74
! 		if (PyDict_SetItemString(ret, (char *)hi->hi_key, newObj))
Karsten Hopp bc8f74
  		{
Karsten Hopp bc8f74
! 		    Py_DECREF(ret);
Karsten Hopp bc8f74
  		    Py_DECREF(newObj);
Karsten Hopp bc8f74
  		    return NULL;
Karsten Hopp bc8f74
  		}
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 739,748 ****
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_INCREF(Py_None);
Karsten Hopp bc8f74
! 	result = Py_None;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return result;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 739,748 ----
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_INCREF(Py_None);
Karsten Hopp bc8f74
! 	ret = Py_None;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 752,758 ****
Karsten Hopp bc8f74
      typval_T	*our_tv;
Karsten Hopp bc8f74
      PyObject	*string;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
!     PyObject	*result;
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!PyArg_ParseTuple(args, "O", &string))
Karsten Hopp bc8f74
--- 752,758 ----
Karsten Hopp bc8f74
      typval_T	*our_tv;
Karsten Hopp bc8f74
      PyObject	*string;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!PyArg_ParseTuple(args, "O", &string))
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 782,791 ****
Karsten Hopp bc8f74
      /* Convert the Vim type into a Python type.  Create a dictionary that's
Karsten Hopp bc8f74
       * used to check for recursive loops. */
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
! 	result = NULL;
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	result = VimToPython(our_tv, 1, lookup_dict);
Karsten Hopp bc8f74
  	Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 782,791 ----
Karsten Hopp bc8f74
      /* Convert the Vim type into a Python type.  Create a dictionary that's
Karsten Hopp bc8f74
       * used to check for recursive loops. */
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
! 	ret = NULL;
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	ret = VimToPython(our_tv, 1, lookup_dict);
Karsten Hopp bc8f74
  	Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 796,802 ****
Karsten Hopp bc8f74
      Python_Release_Vim();
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return result;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static PyObject *ConvertToPyObject(typval_T *);
Karsten Hopp bc8f74
--- 796,802 ----
Karsten Hopp bc8f74
      Python_Release_Vim();
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static PyObject *ConvertToPyObject(typval_T *);
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 805,811 ****
Karsten Hopp bc8f74
  VimEvalPy(PyObject *self UNUSED, PyObject *string)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      typval_T	*our_tv;
Karsten Hopp bc8f74
!     PyObject	*result;
Karsten Hopp bc8f74
      char_u	*expr;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 805,811 ----
Karsten Hopp bc8f74
  VimEvalPy(PyObject *self UNUSED, PyObject *string)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      typval_T	*our_tv;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      char_u	*expr;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 830,843 ****
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     result = ConvertToPyObject(our_tv);
Karsten Hopp bc8f74
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp bc8f74
      Python_Lock_Vim();
Karsten Hopp bc8f74
      free_tv(our_tv);
Karsten Hopp bc8f74
      Python_Release_Vim();
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return result;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 830,843 ----
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = ConvertToPyObject(our_tv);
Karsten Hopp bc8f74
      Py_BEGIN_ALLOW_THREADS
Karsten Hopp bc8f74
      Python_Lock_Vim();
Karsten Hopp bc8f74
      free_tv(our_tv);
Karsten Hopp bc8f74
      Python_Release_Vim();
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 845,888 ****
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      char_u	*str;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
!     int		result;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(str = StringToChars(string, &todecref)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_MBYTE
Karsten Hopp bc8f74
!     result = mb_string2cells(str, (int)STRLEN(str));
Karsten Hopp bc8f74
  #else
Karsten Hopp bc8f74
!     result = STRLEN(str);
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return PyLong_FromLong(result);
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  _VimChdir(PyObject *_chdir, PyObject *args, PyObject *kwargs)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
      PyObject	*newwd;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
      char_u	*new_dir;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (_chdir == NULL)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
!     if (!(r = PyObject_Call(_chdir, args, kwargs)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(newwd = PyObject_CallFunctionObjArgs(py_getcwd, NULL)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(new_dir = StringToChars(newwd, &todecref)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	Py_DECREF(newwd);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
--- 845,888 ----
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      char_u	*str;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
!     int		len;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(str = StringToChars(string, &todecref)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_MBYTE
Karsten Hopp bc8f74
!     len = mb_string2cells(str, (int)STRLEN(str));
Karsten Hopp bc8f74
  #else
Karsten Hopp bc8f74
!     len = STRLEN(str);
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return PyLong_FromLong(len);
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  _VimChdir(PyObject *_chdir, PyObject *args, PyObject *kwargs)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      PyObject	*newwd;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
      char_u	*new_dir;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (_chdir == NULL)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
!     if (!(ret = PyObject_Call(_chdir, args, kwargs)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(newwd = PyObject_CallFunctionObjArgs(py_getcwd, NULL)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(new_dir = StringToChars(newwd, &todecref)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	Py_DECREF(newwd);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 891,897 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (vim_chdir(new_dir))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	Py_DECREF(newwd);
Karsten Hopp bc8f74
  	Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 891,897 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (vim_chdir(new_dir))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	Py_DECREF(newwd);
Karsten Hopp bc8f74
  	Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 909,919 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 909,919 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1052,1071 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  Vim_GetPaths(PyObject *self UNUSED)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = PyList_New(0)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     do_in_runtimepath(NULL, FALSE, &map_finder_callback, r);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (PyErr_Occurred())
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1052,1071 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  Vim_GetPaths(PyObject *self UNUSED)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = PyList_New(0)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     do_in_runtimepath(NULL, FALSE, &map_finder_callback, ret);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (PyErr_Occurred())
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	Py_DECREF(ret);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1400,1415 ****
Karsten Hopp bc8f74
      static dict_T *
Karsten Hopp bc8f74
  py_dict_alloc(void)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     dict_T	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = dict_alloc()))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_NoMemory();
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     ++r->dv_refcount;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1400,1415 ----
Karsten Hopp bc8f74
      static dict_T *
Karsten Hopp bc8f74
  py_dict_alloc(void)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     dict_T	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = dict_alloc()))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_NoMemory();
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     ++ret->dv_refcount;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1461,1469 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! DictionarySetattr(DictionaryObject *self, char *name, PyObject *val)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (val == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"cannot delete vim.Dictionary attributes");
Karsten Hopp bc8f74
--- 1461,1469 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! DictionarySetattr(DictionaryObject *self, char *name, PyObject *valObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (valObject == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"cannot delete vim.Dictionary attributes");
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1479,1485 ****
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    int		istrue = PyObject_IsTrue(val);
Karsten Hopp bc8f74
  	    if (istrue == -1)
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    else if (istrue)
Karsten Hopp bc8f74
--- 1479,1485 ----
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    int		istrue = PyObject_IsTrue(valObject);
Karsten Hopp bc8f74
  	    if (istrue == -1)
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    else if (istrue)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1513,1519 ****
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*keyObject;
Karsten Hopp bc8f74
      PyObject	*defObject = ((flags & DICT_FLAG_NONE_DEFAULT)? Py_None : NULL);
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
      char_u	*key;
Karsten Hopp bc8f74
      dictitem_T	*di;
Karsten Hopp bc8f74
      dict_T	*dict = self->dict;
Karsten Hopp bc8f74
--- 1513,1519 ----
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*keyObject;
Karsten Hopp bc8f74
      PyObject	*defObject = ((flags & DICT_FLAG_NONE_DEFAULT)? Py_None : NULL);
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      char_u	*key;
Karsten Hopp bc8f74
      dictitem_T	*di;
Karsten Hopp bc8f74
      dict_T	*dict = self->dict;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1566,1572 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      di = dict_lookup(hi);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = ConvertToPyObject(&di->di_tv)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (flags & DICT_FLAG_POP)
Karsten Hopp bc8f74
--- 1566,1572 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      di = dict_lookup(hi);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = ConvertToPyObject(&di->di_tv)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (flags & DICT_FLAG_POP)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1574,1580 ****
Karsten Hopp bc8f74
  	if (dict->dv_lock)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    RAISE_LOCKED_DICTIONARY;
Karsten Hopp bc8f74
! 	    Py_DECREF(r);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 1574,1580 ----
Karsten Hopp bc8f74
  	if (dict->dv_lock)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    RAISE_LOCKED_DICTIONARY;
Karsten Hopp bc8f74
! 	    Py_DECREF(ret);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1582,1588 ****
Karsten Hopp bc8f74
  	dictitem_free(di);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1582,1588 ----
Karsten Hopp bc8f74
  	dictitem_free(di);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1595,1607 ****
Karsten Hopp bc8f74
  DictionaryContains(DictionaryObject *self, PyObject *keyObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
Karsten Hopp bc8f74
!     int		r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = (rObj == Py_True);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_DECREF(Py_True);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  typedef struct
Karsten Hopp bc8f74
--- 1595,1607 ----
Karsten Hopp bc8f74
  DictionaryContains(DictionaryObject *self, PyObject *keyObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
Karsten Hopp bc8f74
!     int		ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = (rObj == Py_True);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_DECREF(Py_True);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  typedef struct
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1616,1622 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  DictionaryIterNext(dictiterinfo_T **dii)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(*dii)->todo)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
--- 1616,1622 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  DictionaryIterNext(dictiterinfo_T **dii)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(*dii)->todo)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1634,1643 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      --((*dii)->todo);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = PyBytes_FromString((char *) (*dii)->hi->hi_key)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1634,1643 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      --((*dii)->todo);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = PyBytes_FromString((char *) (*dii)->hi->hi_key)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1753,1778 ****
Karsten Hopp bc8f74
      dict_T	*dict = self->dict;
Karsten Hopp bc8f74
      long_u	todo = dict->dv_hashtab.ht_used;
Karsten Hopp bc8f74
      Py_ssize_t	i = 0;
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
      hashitem_T	*hi;
Karsten Hopp bc8f74
      PyObject	*newObj;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = PyList_New(todo);
Karsten Hopp bc8f74
      for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (!HASHITEM_EMPTY(hi))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (!(newObj = hiconvert(hi)))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(r);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    PyList_SET_ITEM(r, i, newObj);
Karsten Hopp bc8f74
  	    --todo;
Karsten Hopp bc8f74
  	    ++i;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1753,1778 ----
Karsten Hopp bc8f74
      dict_T	*dict = self->dict;
Karsten Hopp bc8f74
      long_u	todo = dict->dv_hashtab.ht_used;
Karsten Hopp bc8f74
      Py_ssize_t	i = 0;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      hashitem_T	*hi;
Karsten Hopp bc8f74
      PyObject	*newObj;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = PyList_New(todo);
Karsten Hopp bc8f74
      for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (!HASHITEM_EMPTY(hi))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (!(newObj = hiconvert(hi)))
Karsten Hopp bc8f74
  	    {
Karsten Hopp bc8f74
! 		Py_DECREF(ret);
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    PyList_SET_ITEM(ret, i, newObj);
Karsten Hopp bc8f74
  	    --todo;
Karsten Hopp bc8f74
  	    ++i;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1807,1813 ****
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*keyObject;
Karsten Hopp bc8f74
      PyObject	*valObject;
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(keyObject = dict_key(hi)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
--- 1807,1813 ----
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*keyObject;
Karsten Hopp bc8f74
      PyObject	*valObject;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(keyObject = dict_key(hi)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1818,1829 ****
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = Py_BuildValue("(OO)", keyObject, valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_DECREF(keyObject);
Karsten Hopp bc8f74
      Py_DECREF(valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 1818,1829 ----
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = Py_BuildValue("(OO)", keyObject, valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_DECREF(keyObject);
Karsten Hopp bc8f74
      Py_DECREF(valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1858,1876 ****
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*object;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!PyArg_ParseTuple(args, "O", &object))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyObject_HasAttrString(object, "keys"))
Karsten Hopp bc8f74
! 	    return DictionaryUpdate(self, NULL, object);
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyObject	*iterator;
Karsten Hopp bc8f74
  	    PyObject	*item;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	    if (!(iterator = PyObject_GetIter(object)))
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	    while ((item = PyIter_Next(iterator)))
Karsten Hopp bc8f74
--- 1858,1876 ----
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*obj;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!PyArg_ParseTuple(args, "O", &obj))
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyObject_HasAttrString(obj, "keys"))
Karsten Hopp bc8f74
! 	    return DictionaryUpdate(self, NULL, obj);
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyObject	*iterator;
Karsten Hopp bc8f74
  	    PyObject	*item;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	    if (!(iterator = PyObject_GetIter(obj)))
Karsten Hopp bc8f74
  		return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	    while ((item = PyIter_Next(iterator)))
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1974,1980 ****
Karsten Hopp bc8f74
  DictionaryPopItem(DictionaryObject *self)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      hashitem_T	*hi;
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
      PyObject	*valObject;
Karsten Hopp bc8f74
      dictitem_T	*di;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 1974,1980 ----
Karsten Hopp bc8f74
  DictionaryPopItem(DictionaryObject *self)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      hashitem_T	*hi;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      PyObject	*valObject;
Karsten Hopp bc8f74
      dictitem_T	*di;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 1993,1999 ****
Karsten Hopp bc8f74
      if (!(valObject = ConvertToPyObject(&di->di_tv)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, valObject)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_DECREF(valObject);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
--- 1993,1999 ----
Karsten Hopp bc8f74
      if (!(valObject = ConvertToPyObject(&di->di_tv)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, valObject)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	Py_DECREF(valObject);
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2002,2008 ****
Karsten Hopp bc8f74
      hash_remove(&self->dict->dv_hashtab, hi);
Karsten Hopp bc8f74
      dictitem_free(di);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 2002,2008 ----
Karsten Hopp bc8f74
      hash_remove(&self->dict->dv_hashtab, hi);
Karsten Hopp bc8f74
      dictitem_free(di);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2075,2090 ****
Karsten Hopp bc8f74
      static list_T *
Karsten Hopp bc8f74
  py_list_alloc()
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     list_T	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = list_alloc()))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_NoMemory();
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     ++r->lv_refcount;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
--- 2075,2090 ----
Karsten Hopp bc8f74
      static list_T *
Karsten Hopp bc8f74
  py_list_alloc()
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     list_T	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = list_alloc()))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_NoMemory();
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     ++ret->lv_refcount;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2272,2288 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  ListIterNext(listiterinfo_T **lii)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!((*lii)->lw.lw_item))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(r = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 2272,2288 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  ListIterNext(listiterinfo_T **lii)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!((*lii)->lw.lw_item))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!(ret = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2319,2325 ****
Karsten Hopp bc8f74
  	RAISE_LOCKED_LIST;
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     if (index>length || (index==length && obj==NULL))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_IndexError, "list index out of range");
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
--- 2319,2325 ----
Karsten Hopp bc8f74
  	RAISE_LOCKED_LIST;
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
!     if (index > length || (index == length && obj == NULL))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_IndexError, "list index out of range");
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2463,2471 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! ListSetattr(ListObject *self, char *name, PyObject *val)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (val == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"cannot delete vim.List attributes");
Karsten Hopp bc8f74
--- 2463,2471 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! ListSetattr(ListObject *self, char *name, PyObject *valObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     if (valObject == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_SET_STRING(PyExc_AttributeError,
Karsten Hopp bc8f74
  		"cannot delete vim.List attributes");
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2481,2487 ****
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    int		istrue = PyObject_IsTrue(val);
Karsten Hopp bc8f74
  	    if (istrue == -1)
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    else if (istrue)
Karsten Hopp bc8f74
--- 2481,2487 ----
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    int		istrue = PyObject_IsTrue(valObject);
Karsten Hopp bc8f74
  	    if (istrue == -1)
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    else if (istrue)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2599,2605 ****
Karsten Hopp bc8f74
      typval_T	rettv;
Karsten Hopp bc8f74
      dict_T	*selfdict = NULL;
Karsten Hopp bc8f74
      PyObject	*selfdictObject;
Karsten Hopp bc8f74
!     PyObject	*result;
Karsten Hopp bc8f74
      int		error;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (ConvertFromPyObject(argsObject, &args) == -1)
Karsten Hopp bc8f74
--- 2599,2605 ----
Karsten Hopp bc8f74
      typval_T	rettv;
Karsten Hopp bc8f74
      dict_T	*selfdict = NULL;
Karsten Hopp bc8f74
      PyObject	*selfdictObject;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
      int		error;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (ConvertFromPyObject(argsObject, &args) == -1)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2629,2649 ****
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
! 	result = NULL;
Karsten Hopp bc8f74
      else if (error != OK)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	result = NULL;
Karsten Hopp bc8f74
  	PyErr_VIM_FORMAT("failed to run function %s", (char *)name);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
! 	result = ConvertToPyObject(&rettv);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      clear_tv(&args);
Karsten Hopp bc8f74
      clear_tv(&rettv);
Karsten Hopp bc8f74
      if (selfdict != NULL)
Karsten Hopp bc8f74
  	clear_tv(&selfdicttv);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return result;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 2629,2649 ----
Karsten Hopp bc8f74
      Py_END_ALLOW_THREADS
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (VimTryEnd())
Karsten Hopp bc8f74
! 	ret = NULL;
Karsten Hopp bc8f74
      else if (error != OK)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	ret = NULL;
Karsten Hopp bc8f74
  	PyErr_VIM_FORMAT("failed to run function %s", (char *)name);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
! 	ret = ConvertToPyObject(&rettv);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      clear_tv(&args);
Karsten Hopp bc8f74
      clear_tv(&rettv);
Karsten Hopp bc8f74
      if (selfdict != NULL)
Karsten Hopp bc8f74
  	clear_tv(&selfdicttv);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2761,2770 ****
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_BOOL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*r;
Karsten Hopp bc8f74
! 	r = numval ? Py_True : Py_False;
Karsten Hopp bc8f74
! 	Py_INCREF(r);
Karsten Hopp bc8f74
! 	return r;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_NUM)
Karsten Hopp bc8f74
  	return PyInt_FromLong(numval);
Karsten Hopp bc8f74
--- 2761,2770 ----
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_BOOL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*ret;
Karsten Hopp bc8f74
! 	ret = numval ? Py_True : Py_False;
Karsten Hopp bc8f74
! 	Py_INCREF(ret);
Karsten Hopp bc8f74
! 	return ret;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_NUM)
Karsten Hopp bc8f74
  	return PyInt_FromLong(numval);
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2772,2780 ****
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (stringval)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    PyObject	*r = PyBytes_FromString((char *) stringval);
Karsten Hopp bc8f74
  	    vim_free(stringval);
Karsten Hopp bc8f74
! 	    return r;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
--- 2772,2780 ----
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (stringval)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
! 	    PyObject	*ret = PyBytes_FromString((char *) stringval);
Karsten Hopp bc8f74
  	    vim_free(stringval);
Karsten Hopp bc8f74
! 	    return ret;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2817,2823 ****
Karsten Hopp bc8f74
      win_T	*save_curwin = NULL;
Karsten Hopp bc8f74
      tabpage_T	*save_curtab = NULL;
Karsten Hopp bc8f74
      buf_T	*save_curbuf = NULL;
Karsten Hopp bc8f74
!     int		r = 0;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      VimTryStart();
Karsten Hopp bc8f74
      switch (opt_type)
Karsten Hopp bc8f74
--- 2817,2823 ----
Karsten Hopp bc8f74
      win_T	*save_curwin = NULL;
Karsten Hopp bc8f74
      tabpage_T	*save_curtab = NULL;
Karsten Hopp bc8f74
      buf_T	*save_curbuf = NULL;
Karsten Hopp bc8f74
!     int		set_ret = 0;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      VimTryStart();
Karsten Hopp bc8f74
      switch (opt_type)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2831,2854 ****
Karsten Hopp bc8f74
  		PyErr_SET_VIM("problem while switching windows");
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    r = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
! 	    restore_win(save_curwin, save_curtab, FALSE);
Karsten Hopp bc8f74
! 	    if (r == FAIL)
Karsten Hopp bc8f74
! 		return -1;
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
  	case SREQ_BUF:
Karsten Hopp bc8f74
  	    switch_buffer(&save_curbuf, (buf_T *)from);
Karsten Hopp bc8f74
! 	    r = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
  	    restore_buffer(save_curbuf);
Karsten Hopp bc8f74
- 	    if (r == FAIL)
Karsten Hopp bc8f74
- 		return -1;
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
  	case SREQ_GLOBAL:
Karsten Hopp bc8f74
! 	    r = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
! 	    if (r == FAIL)
Karsten Hopp bc8f74
! 		return -1;
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      return VimTryEnd();
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 2831,2850 ----
Karsten Hopp bc8f74
  		PyErr_SET_VIM("problem while switching windows");
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
  	    }
Karsten Hopp bc8f74
! 	    set_ret = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
! 	    restore_win(save_curwin, save_curtab, TRUE);
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
  	case SREQ_BUF:
Karsten Hopp bc8f74
  	    switch_buffer(&save_curbuf, (buf_T *)from);
Karsten Hopp bc8f74
! 	    set_ret = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
  	    restore_buffer(save_curbuf);
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
  	case SREQ_GLOBAL:
Karsten Hopp bc8f74
! 	    set_ret = set_option_value_err(key, numval, stringval, opt_flags);
Karsten Hopp bc8f74
  	    break;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
+     if (set_ret == FAIL)
Karsten Hopp bc8f74
+ 	return -1;
Karsten Hopp bc8f74
      return VimTryEnd();
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2858,2864 ****
Karsten Hopp bc8f74
      char_u	*key;
Karsten Hopp bc8f74
      int		flags;
Karsten Hopp bc8f74
      int		opt_flags;
Karsten Hopp bc8f74
!     int		r = 0;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (self->Check(self->from))
Karsten Hopp bc8f74
--- 2854,2860 ----
Karsten Hopp bc8f74
      char_u	*key;
Karsten Hopp bc8f74
      int		flags;
Karsten Hopp bc8f74
      int		opt_flags;
Karsten Hopp bc8f74
!     int		ret = 0;
Karsten Hopp bc8f74
      PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (self->Check(self->from))
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2916,2924 ****
Karsten Hopp bc8f74
  	int	istrue = PyObject_IsTrue(valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (istrue == -1)
Karsten Hopp bc8f74
! 	    r = -1;
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
! 	    r = set_option_value_for(key, istrue, NULL,
Karsten Hopp bc8f74
  				    opt_flags, self->opt_type, self->from);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_NUM)
Karsten Hopp bc8f74
--- 2912,2920 ----
Karsten Hopp bc8f74
  	int	istrue = PyObject_IsTrue(valObject);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (istrue == -1)
Karsten Hopp bc8f74
! 	    ret = -1;
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
! 	    ret = set_option_value_for(key, istrue, NULL,
Karsten Hopp bc8f74
  				    opt_flags, self->opt_type, self->from);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (flags & SOPT_NUM)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 2931,2954 ****
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	r = set_option_value_for(key, (int) val, NULL, opt_flags,
Karsten Hopp bc8f74
  				self->opt_type, self->from);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u	*val;
Karsten Hopp bc8f74
  	PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if ((val = StringToChars(valObject, &todecref)))
Karsten Hopp bc8f74
! 	    r = set_option_value_for(key, 0, val, opt_flags,
Karsten Hopp bc8f74
  				    self->opt_type, self->from);
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
! 	    r = -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static PyMappingMethods OptionsAsMapping = {
Karsten Hopp bc8f74
--- 2927,2950 ----
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	ret = set_option_value_for(key, (int) val, NULL, opt_flags,
Karsten Hopp bc8f74
  				self->opt_type, self->from);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u		*val;
Karsten Hopp bc8f74
  	PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if ((val = StringToChars(valObject, &todecref)))
Karsten Hopp bc8f74
! 	    ret = set_option_value_for(key, 0, val, opt_flags,
Karsten Hopp bc8f74
  				    self->opt_type, self->from);
Karsten Hopp bc8f74
  	else
Karsten Hopp bc8f74
! 	    ret = -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      Py_XDECREF(todecref);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static PyMappingMethods OptionsAsMapping = {
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3027,3040 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  TabPageAttrValid(TabPageObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject *r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = ((self->tab == INVALID_TABPAGE_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(r);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 3023,3036 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  TabPageAttrValid(TabPageObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = ((self->tab == INVALID_TABPAGE_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(ret);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3243,3256 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  WindowAttrValid(WindowObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject *r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = ((self->win == INVALID_WINDOW_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(r);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 3239,3252 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  WindowAttrValid(WindowObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = ((self->win == INVALID_WINDOW_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(ret);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3300,3306 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! WindowSetattr(WindowObject *self, char *name, PyObject *val)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      if (CheckWindow(self))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
--- 3296,3302 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      if (CheckWindow(self))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3315,3321 ****
Karsten Hopp bc8f74
  	long lnum;
Karsten Hopp bc8f74
  	long col;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!PyArg_Parse(val, "(ll)", &lnum, &col))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (lnum <= 0 || lnum > self->win->w_buffer->b_ml.ml_line_count)
Karsten Hopp bc8f74
--- 3311,3317 ----
Karsten Hopp bc8f74
  	long lnum;
Karsten Hopp bc8f74
  	long col;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (!PyArg_Parse(valObject, "(ll)", &lnum, &col))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (lnum <= 0 || lnum > self->win->w_buffer->b_ml.ml_line_count)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3344,3350 ****
Karsten Hopp bc8f74
  	long	height;
Karsten Hopp bc8f74
  	win_T	*savewin;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (NumberToLong(val, &height, NUMBER_INT))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_GUI
Karsten Hopp bc8f74
--- 3340,3346 ----
Karsten Hopp bc8f74
  	long	height;
Karsten Hopp bc8f74
  	win_T	*savewin;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (NumberToLong(valObject, &height, NUMBER_INT))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_GUI
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3367,3373 ****
Karsten Hopp bc8f74
  	long	width;
Karsten Hopp bc8f74
  	win_T	*savewin;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (NumberToLong(val, &width, NUMBER_INT))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_GUI
Karsten Hopp bc8f74
--- 3363,3369 ----
Karsten Hopp bc8f74
  	long	width;
Karsten Hopp bc8f74
  	win_T	*savewin;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (NumberToLong(valObject, &width, NUMBER_INT))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef FEAT_GUI
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3584,3608 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyInt i;
Karsten Hopp bc8f74
!     PyInt n = hi - lo;
Karsten Hopp bc8f74
!     PyObject *list = PyList_New(n);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (list == NULL)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (i = 0; i < n; ++i)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject *str = LineToString((char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	/* Error check - was the Python string creation OK? */
Karsten Hopp bc8f74
! 	if (str == NULL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_DECREF(list);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	PyList_SET_ITEM(list, i, str);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      /* The ownership of the Python list is passed to the caller (ie,
Karsten Hopp bc8f74
--- 3580,3605 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyInt	i;
Karsten Hopp bc8f74
!     PyInt	n = hi - lo;
Karsten Hopp bc8f74
!     PyObject	*list = PyList_New(n);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (list == NULL)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (i = 0; i < n; ++i)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*string = LineToString(
Karsten Hopp bc8f74
! 		(char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	/* Error check - was the Python string creation OK? */
Karsten Hopp bc8f74
! 	if (string == NULL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_DECREF(list);
Karsten Hopp bc8f74
  	    return NULL;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	PyList_SET_ITEM(list, i, string);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      /* The ownership of the Python list is passed to the caller (ie,
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3662,3668 ****
Karsten Hopp bc8f74
       */
Karsten Hopp bc8f74
      if (line == Py_None || line == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	buf_T *savebuf;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	PyErr_Clear();
Karsten Hopp bc8f74
  	switch_buffer(&savebuf, buf);
Karsten Hopp bc8f74
--- 3659,3665 ----
Karsten Hopp bc8f74
       */
Karsten Hopp bc8f74
      if (line == Py_None || line == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	buf_T	*savebuf;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	PyErr_Clear();
Karsten Hopp bc8f74
  	switch_buffer(&savebuf, buf);
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 3747,3753 ****
Karsten Hopp bc8f74
   * is set to the change in the buffer length.
Karsten Hopp bc8f74
   */
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, PyInt *len_change)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      /* First of all, we check the type of the supplied Python object.
Karsten Hopp bc8f74
       * There are three cases:
Karsten Hopp bc8f74
--- 3744,3755 ----
Karsten Hopp bc8f74
   * is set to the change in the buffer length.
Karsten Hopp bc8f74
   */
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! SetBufferLineList(
Karsten Hopp bc8f74
! 	buf_T *buf,
Karsten Hopp bc8f74
! 	PyInt lo,
Karsten Hopp bc8f74
! 	PyInt hi,
Karsten Hopp bc8f74
! 	PyObject *list,
Karsten Hopp bc8f74
! 	PyInt *len_change)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      /* First of all, we check the type of the supplied Python object.
Karsten Hopp bc8f74
       * There are three cases:
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4124,4130 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyInt
Karsten Hopp bc8f74
! RBAsItem(BufferObject *self, PyInt n, PyObject *val, PyInt start, PyInt end, PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
--- 4126,4138 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyInt
Karsten Hopp bc8f74
! RBAsItem(
Karsten Hopp bc8f74
! 	BufferObject *self,
Karsten Hopp bc8f74
! 	PyInt n,
Karsten Hopp bc8f74
! 	PyObject *valObject,
Karsten Hopp bc8f74
! 	PyInt start,
Karsten Hopp bc8f74
! 	PyInt end,
Karsten Hopp bc8f74
! 	PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4143,4149 ****
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (SetBufferLine(self->buf, n+start, val, &len_change) == FAIL)
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (new_end)
Karsten Hopp bc8f74
--- 4151,4157 ----
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (SetBufferLine(self->buf, n+start, valObject, &len_change) == FAIL)
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (new_end)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4153,4159 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyInt
Karsten Hopp bc8f74
! RBAsSlice(BufferObject *self, PyInt lo, PyInt hi, PyObject *val, PyInt start, PyInt end, PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyInt size;
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
--- 4161,4174 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyInt
Karsten Hopp bc8f74
! RBAsSlice(
Karsten Hopp bc8f74
! 	BufferObject *self,
Karsten Hopp bc8f74
! 	PyInt lo,
Karsten Hopp bc8f74
! 	PyInt hi,
Karsten Hopp bc8f74
! 	PyObject *valObject,
Karsten Hopp bc8f74
! 	PyInt start,
Karsten Hopp bc8f74
! 	PyInt end,
Karsten Hopp bc8f74
! 	PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyInt size;
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4180,4186 ****
Karsten Hopp bc8f74
  	hi = size;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (SetBufferLineList(self->buf, lo + start, hi + start,
Karsten Hopp bc8f74
! 						    val, &len_change) == FAIL)
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (new_end)
Karsten Hopp bc8f74
--- 4195,4201 ----
Karsten Hopp bc8f74
  	hi = size;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (SetBufferLineList(self->buf, lo + start, hi + start,
Karsten Hopp bc8f74
! 						valObject, &len_change) == FAIL)
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (new_end)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4191,4197 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
! RBAppend(BufferObject *self, PyObject *args, PyInt start, PyInt end, PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject *lines;
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
--- 4206,4217 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
! RBAppend(
Karsten Hopp bc8f74
! 	BufferObject *self,
Karsten Hopp bc8f74
! 	PyObject *args,
Karsten Hopp bc8f74
! 	PyInt start,
Karsten Hopp bc8f74
! 	PyInt end,
Karsten Hopp bc8f74
! 	PyInt *new_end)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject *lines;
Karsten Hopp bc8f74
      PyInt len_change;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4438,4451 ****
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  BufferAttrValid(BufferObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject *r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = ((self->buf == INVALID_BUFFER_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(r);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 4458,4471 ----
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
  BufferAttrValid(BufferObject *self, char *name)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "valid") != 0)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = ((self->buf == INVALID_BUFFER_VALUE) ? Py_False : Py_True);
Karsten Hopp bc8f74
!     Py_INCREF(ret);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4475,4483 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "name") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u	*val;
Karsten Hopp bc8f74
  	aco_save_T	aco;
Karsten Hopp bc8f74
! 	int	r;
Karsten Hopp bc8f74
  	PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (!(val = StringToChars(valObject, &todecref)))
Karsten Hopp bc8f74
--- 4495,4503 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (strcmp(name, "name") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u		*val;
Karsten Hopp bc8f74
  	aco_save_T	aco;
Karsten Hopp bc8f74
! 	int		ren_ret;
Karsten Hopp bc8f74
  	PyObject	*todecref;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (!(val = StringToChars(valObject, &todecref)))
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4486,4498 ****
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
  	/* Using aucmd_*: autocommands will be executed by rename_buffer */
Karsten Hopp bc8f74
  	aucmd_prepbuf(&aco, self->buf);
Karsten Hopp bc8f74
! 	r = rename_buffer(val);
Karsten Hopp bc8f74
  	aucmd_restbuf(&aco;;
Karsten Hopp bc8f74
  	Py_XDECREF(todecref);
Karsten Hopp bc8f74
  	if (VimTryEnd())
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (r == FAIL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_SET_VIM("failed to rename buffer");
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
--- 4506,4518 ----
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
  	/* Using aucmd_*: autocommands will be executed by rename_buffer */
Karsten Hopp bc8f74
  	aucmd_prepbuf(&aco, self->buf);
Karsten Hopp bc8f74
! 	ren_ret = rename_buffer(val);
Karsten Hopp bc8f74
  	aucmd_restbuf(&aco;;
Karsten Hopp bc8f74
  	Py_XDECREF(todecref);
Karsten Hopp bc8f74
  	if (VimTryEnd())
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (ren_ret == FAIL)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_SET_VIM("failed to rename buffer");
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4677,4703 ****
Karsten Hopp bc8f74
  BufMapIterNext(PyObject **buffer)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*next;
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!*buffer)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = *buffer;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (CheckBuffer((BufferObject *)(r)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	*buffer = NULL;
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!((BufferObject *)(r))->buf->b_next)
Karsten Hopp bc8f74
  	next = NULL;
Karsten Hopp bc8f74
!     else if (!(next = BufferNew(((BufferObject *)(r))->buf->b_next)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      *buffer = next;
Karsten Hopp bc8f74
      /* Do not increment reference: we no longer hold it (decref), but whoever
Karsten Hopp bc8f74
       * on other side will hold (incref). Decref+incref = nothing. */
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
--- 4697,4723 ----
Karsten Hopp bc8f74
  BufMapIterNext(PyObject **buffer)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*next;
Karsten Hopp bc8f74
!     PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!*buffer)
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     ret = *buffer;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (CheckBuffer((BufferObject *)(ret)))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	*buffer = NULL;
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     if (!((BufferObject *)(ret))->buf->b_next)
Karsten Hopp bc8f74
  	next = NULL;
Karsten Hopp bc8f74
!     else if (!(next = BufferNew(((BufferObject *)(ret))->buf->b_next)))
Karsten Hopp bc8f74
  	return NULL;
Karsten Hopp bc8f74
      *buffer = next;
Karsten Hopp bc8f74
      /* Do not increment reference: we no longer hold it (decref), but whoever
Karsten Hopp bc8f74
       * on other side will hold (incref). Decref+incref = nothing. */
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static PyObject *
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4755,4765 ****
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! CurrentSetattr(PyObject *self UNUSED, char *name, PyObject *value)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      if (strcmp(name, "line") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (SetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum, value, NULL) == FAIL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	return 0;
Karsten Hopp bc8f74
--- 4775,4786 ----
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
! CurrentSetattr(PyObject *self UNUSED, char *name, PyObject *valObject)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      if (strcmp(name, "line") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (SetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum, valObject,
Karsten Hopp bc8f74
! 			  NULL) == FAIL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	return 0;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4768,4784 ****
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	int count;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (value->ob_type != &BufferType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.Buffer object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(value));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckBuffer((BufferObject *)(value)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	count = ((BufferObject *)(value))->buf->b_fnum;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
  	if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL)
Karsten Hopp bc8f74
--- 4789,4805 ----
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	int count;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (valObject->ob_type != &BufferType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.Buffer object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(valObject));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckBuffer((BufferObject *)(valObject)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	count = ((BufferObject *)(valObject))->buf->b_fnum;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
  	if (do_buffer(DOBUF_GOTO, DOBUF_FIRST, FORWARD, count, 0) == FAIL)
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4795,4811 ****
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	int count;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (value->ob_type != &WindowType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.Window object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(value));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckWindow((WindowObject *)(value)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	count = get_win_number(((WindowObject *)(value))->win, firstwin);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (!count)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
--- 4816,4832 ----
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	int count;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (valObject->ob_type != &WindowType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.Window object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(valObject));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckWindow((WindowObject *)(valObject)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	count = get_win_number(((WindowObject *)(valObject))->win, firstwin);
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	if (!count)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4815,4822 ****
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
! 	win_goto(((WindowObject *)(value))->win);
Karsten Hopp bc8f74
! 	if (((WindowObject *)(value))->win != curwin)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (VimTryEnd())
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
--- 4836,4843 ----
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
! 	win_goto(((WindowObject *)(valObject))->win);
Karsten Hopp bc8f74
! 	if (((WindowObject *)(valObject))->win != curwin)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (VimTryEnd())
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4829,4848 ****
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (strcmp(name, "tabpage") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (value->ob_type != &TabPageType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.TabPage object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(value));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckTabPage((TabPageObject *)(value)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
! 	goto_tabpage_tp(((TabPageObject *)(value))->tab, TRUE, TRUE);
Karsten Hopp bc8f74
! 	if (((TabPageObject *)(value))->tab != curtab)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (VimTryEnd())
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
--- 4850,4869 ----
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (strcmp(name, "tabpage") == 0)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (valObject->ob_type != &TabPageType)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		    "expected vim.TabPage object, but got %s",
Karsten Hopp bc8f74
! 		    Py_TYPE_NAME(valObject));
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  	}
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (CheckTabPage((TabPageObject *)(valObject)))
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	VimTryStart();
Karsten Hopp bc8f74
! 	goto_tabpage_tp(((TabPageObject *)(valObject))->tab, TRUE, TRUE);
Karsten Hopp bc8f74
! 	if (((TabPageObject *)(valObject))->tab != curtab)
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    if (VimTryEnd())
Karsten Hopp bc8f74
  		return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4934,4940 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (lnum = RangeStart; lnum <= RangeEnd; ++lnum)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*line, *linenr, *ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef PY_CAN_RECURSE
Karsten Hopp bc8f74
  	*pygilstate = PyGILState_Ensure();
Karsten Hopp bc8f74
--- 4955,4963 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (lnum = RangeStart; lnum <= RangeEnd; ++lnum)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*line;
Karsten Hopp bc8f74
! 	PyObject	*linenr;
Karsten Hopp bc8f74
! 	PyObject	*ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #ifdef PY_CAN_RECURSE
Karsten Hopp bc8f74
  	*pygilstate = PyGILState_Ensure();
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 4990,4999 ****
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  	)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     r = PyRun_String((char *) cmd, Py_eval_input, globals, globals);
Karsten Hopp bc8f74
!     if (r == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (PyErr_Occurred() && !msg_silent)
Karsten Hopp bc8f74
  	    PyErr_PrintEx(0);
Karsten Hopp bc8f74
--- 5013,5022 ----
Karsten Hopp bc8f74
  #endif
Karsten Hopp bc8f74
  	)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
!     PyObject	*run_ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
!     run_ret = PyRun_String((char *) cmd, Py_eval_input, globals, globals);
Karsten Hopp bc8f74
!     if (run_ret == NULL)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	if (PyErr_Occurred() && !msg_silent)
Karsten Hopp bc8f74
  	    PyErr_PrintEx(0);
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5001,5009 ****
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (ConvertFromPyObject(r, rettv) == -1)
Karsten Hopp bc8f74
  	    EMSG(_("E859: Failed to convert returned python object to vim value"));
Karsten Hopp bc8f74
! 	Py_DECREF(r);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      PyErr_Clear();
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
--- 5024,5032 ----
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	if (ConvertFromPyObject(run_ret, rettv) == -1)
Karsten Hopp bc8f74
  	    EMSG(_("E859: Failed to convert returned python object to vim value"));
Karsten Hopp bc8f74
! 	Py_DECREF(run_ret);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      PyErr_Clear();
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5306,5312 ****
Karsten Hopp bc8f74
  ConvertFromPyMapping(PyObject *obj, typval_T *tv)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
!     int		r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
--- 5329,5335 ----
Karsten Hopp bc8f74
  ConvertFromPyMapping(PyObject *obj, typval_T *tv)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
!     int		ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5316,5349 ****
Karsten Hopp bc8f74
  	tv->v_type = VAR_DICT;
Karsten Hopp bc8f74
  	tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
Karsten Hopp bc8f74
  	++tv->vval.v_dict->dv_refcount;
Karsten Hopp bc8f74
! 	r = 0;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (PyDict_Check(obj))
Karsten Hopp bc8f74
! 	r = convert_dl(obj, tv, pydict_to_tv, lookup_dict);
Karsten Hopp bc8f74
      else if (PyMapping_Check(obj))
Karsten Hopp bc8f74
! 	r = convert_dl(obj, tv, pymap_to_tv, lookup_dict);
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		"unable to convert %s to vim dictionary",
Karsten Hopp bc8f74
  		Py_TYPE_NAME(obj));
Karsten Hopp bc8f74
! 	r = -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
  ConvertFromPyObject(PyObject *obj, typval_T *tv)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
!     int		r;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
!     r = _ConvertFromPyObject(obj, tv, lookup_dict);
Karsten Hopp bc8f74
      Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
!     return r;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
--- 5339,5372 ----
Karsten Hopp bc8f74
  	tv->v_type = VAR_DICT;
Karsten Hopp bc8f74
  	tv->vval.v_dict = (((DictionaryObject *)(obj))->dict);
Karsten Hopp bc8f74
  	++tv->vval.v_dict->dv_refcount;
Karsten Hopp bc8f74
! 	ret = 0;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (PyDict_Check(obj))
Karsten Hopp bc8f74
! 	ret = convert_dl(obj, tv, pydict_to_tv, lookup_dict);
Karsten Hopp bc8f74
      else if (PyMapping_Check(obj))
Karsten Hopp bc8f74
! 	ret = convert_dl(obj, tv, pymap_to_tv, lookup_dict);
Karsten Hopp bc8f74
      else
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp bc8f74
  		"unable to convert %s to vim dictionary",
Karsten Hopp bc8f74
  		Py_TYPE_NAME(obj));
Karsten Hopp bc8f74
! 	ret = -1;
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
  ConvertFromPyObject(PyObject *obj, typval_T *tv)
Karsten Hopp bc8f74
  {
Karsten Hopp bc8f74
      PyObject	*lookup_dict;
Karsten Hopp bc8f74
!     int		ret;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(lookup_dict = PyDict_New()))
Karsten Hopp bc8f74
  	return -1;
Karsten Hopp bc8f74
!     ret = _ConvertFromPyObject(obj, tv, lookup_dict);
Karsten Hopp bc8f74
      Py_DECREF(lookup_dict);
Karsten Hopp bc8f74
!     return ret;
Karsten Hopp bc8f74
  }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5371,5384 ****
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (PyBytes_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u	*result;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyBytes_AsStringAndSize(obj, (char **) &result, NULL) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	if (result == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (set_string_copy(result, tv) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	tv->v_type = VAR_STRING;
Karsten Hopp bc8f74
--- 5394,5407 ----
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
      else if (PyBytes_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	char_u	*str;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (PyBytes_AsStringAndSize(obj, (char **) &str, NULL) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	if (str == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (set_string_copy(str, tv) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	tv->v_type = VAR_STRING;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5386,5403 ****
Karsten Hopp bc8f74
      else if (PyUnicode_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyObject	*bytes;
Karsten Hopp bc8f74
! 	char_u	*result;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL);
Karsten Hopp bc8f74
  	if (bytes == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if(PyBytes_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	if (result == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (set_string_copy(result, tv))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_XDECREF(bytes);
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
--- 5409,5426 ----
Karsten Hopp bc8f74
      else if (PyUnicode_Check(obj))
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
  	PyObject	*bytes;
Karsten Hopp bc8f74
! 	char_u	*str;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  	bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL);
Karsten Hopp bc8f74
  	if (bytes == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if(PyBytes_AsStringAndSize(bytes, (char **) &str, NULL) == -1)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
! 	if (str == NULL)
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	if (set_string_copy(str, tv))
Karsten Hopp bc8f74
  	{
Karsten Hopp bc8f74
  	    Py_XDECREF(bytes);
Karsten Hopp bc8f74
  	    return -1;
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5852,5858 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct numeric_constant {
Karsten Hopp bc8f74
      char	*name;
Karsten Hopp bc8f74
!     int		value;
Karsten Hopp bc8f74
  } numeric_constants[] = {
Karsten Hopp bc8f74
      {"VAR_LOCKED",	VAR_LOCKED},
Karsten Hopp bc8f74
      {"VAR_FIXED",	VAR_FIXED},
Karsten Hopp bc8f74
--- 5875,5881 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct numeric_constant {
Karsten Hopp bc8f74
      char	*name;
Karsten Hopp bc8f74
!     int		val;
Karsten Hopp bc8f74
  } numeric_constants[] = {
Karsten Hopp bc8f74
      {"VAR_LOCKED",	VAR_LOCKED},
Karsten Hopp bc8f74
      {"VAR_FIXED",	VAR_FIXED},
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5862,5868 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct object_constant {
Karsten Hopp bc8f74
      char	*name;
Karsten Hopp bc8f74
!     PyObject	*value;
Karsten Hopp bc8f74
  } object_constants[] = {
Karsten Hopp bc8f74
      {"buffers",  (PyObject *)(void *)&TheBufferMap},
Karsten Hopp bc8f74
      {"windows",  (PyObject *)(void *)&TheWindowList},
Karsten Hopp bc8f74
--- 5885,5891 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  static struct object_constant {
Karsten Hopp bc8f74
      char	*name;
Karsten Hopp bc8f74
!     PyObject	*valObject;
Karsten Hopp bc8f74
  } object_constants[] = {
Karsten Hopp bc8f74
      {"buffers",  (PyObject *)(void *)&TheBufferMap},
Karsten Hopp bc8f74
      {"windows",  (PyObject *)(void *)&TheWindowList},
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5889,5898 ****
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #define ADD_CHECKED_OBJECT(m, name, obj) \
Karsten Hopp bc8f74
      { \
Karsten Hopp bc8f74
! 	PyObject	*value = obj; \
Karsten Hopp bc8f74
! 	if (!value) \
Karsten Hopp bc8f74
  	    return -1; \
Karsten Hopp bc8f74
! 	ADD_OBJECT(m, name, value); \
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
--- 5912,5921 ----
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
  #define ADD_CHECKED_OBJECT(m, name, obj) \
Karsten Hopp bc8f74
      { \
Karsten Hopp bc8f74
! 	PyObject	*valObject = obj; \
Karsten Hopp bc8f74
! 	if (!valObject) \
Karsten Hopp bc8f74
  	    return -1; \
Karsten Hopp bc8f74
! 	ADD_OBJECT(m, name, valObject); \
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      static int
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 5907,5923 ****
Karsten Hopp bc8f74
  					   / sizeof(struct numeric_constant));
Karsten Hopp bc8f74
  	    ++i)
Karsten Hopp bc8f74
  	ADD_CHECKED_OBJECT(m, numeric_constants[i].name,
Karsten Hopp bc8f74
! 		PyInt_FromLong(numeric_constants[i].value));
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (i = 0; i < (int)(sizeof(object_constants)
Karsten Hopp bc8f74
  					    / sizeof(struct object_constant));
Karsten Hopp bc8f74
  	    ++i)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*value;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	value = object_constants[i].value;
Karsten Hopp bc8f74
! 	Py_INCREF(value);
Karsten Hopp bc8f74
! 	ADD_OBJECT(m, object_constants[i].name, value);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(VimError = PyErr_NewException("vim.error", NULL, NULL)))
Karsten Hopp bc8f74
--- 5930,5946 ----
Karsten Hopp bc8f74
  					   / sizeof(struct numeric_constant));
Karsten Hopp bc8f74
  	    ++i)
Karsten Hopp bc8f74
  	ADD_CHECKED_OBJECT(m, numeric_constants[i].name,
Karsten Hopp bc8f74
! 		PyInt_FromLong(numeric_constants[i].val));
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      for (i = 0; i < (int)(sizeof(object_constants)
Karsten Hopp bc8f74
  					    / sizeof(struct object_constant));
Karsten Hopp bc8f74
  	    ++i)
Karsten Hopp bc8f74
      {
Karsten Hopp bc8f74
! 	PyObject	*valObject;
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
! 	valObject = object_constants[i].valObject;
Karsten Hopp bc8f74
! 	Py_INCREF(valObject);
Karsten Hopp bc8f74
! 	ADD_OBJECT(m, object_constants[i].name, valObject);
Karsten Hopp bc8f74
      }
Karsten Hopp bc8f74
  
Karsten Hopp bc8f74
      if (!(VimError = PyErr_NewException("vim.error", NULL, NULL)))
Karsten Hopp bc8f74
*** ../vim-7.3.1231/src/version.c	2013-06-23 14:16:53.000000000 +0200
Karsten Hopp bc8f74
--- src/version.c	2013-06-23 14:27:07.000000000 +0200
Karsten Hopp bc8f74
***************
Karsten Hopp bc8f74
*** 730,731 ****
Karsten Hopp bc8f74
--- 730,733 ----
Karsten Hopp bc8f74
  {   /* Add new patch number below this line */
Karsten Hopp bc8f74
+ /**/
Karsten Hopp bc8f74
+     1232,
Karsten Hopp bc8f74
  /**/
Karsten Hopp bc8f74
Karsten Hopp bc8f74
-- 
Karsten Hopp bc8f74
Ten bugs in the hand is better than one as yet undetected.
Karsten Hopp bc8f74
Karsten Hopp bc8f74
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bc8f74
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bc8f74
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp bc8f74
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///