astepano / rpms / vim

Forked from rpms/vim 6 years ago
Clone
ffc55f2
To: vim_dev@googlegroups.com
ffc55f2
Subject: Patch 7.3.941
ffc55f2
Fcc: outbox
ffc55f2
From: Bram Moolenaar <Bram@moolenaar.net>
ffc55f2
Mime-Version: 1.0
ffc55f2
Content-Type: text/plain; charset=UTF-8
ffc55f2
Content-Transfer-Encoding: 8bit
ffc55f2
------------
ffc55f2
ffc55f2
Patch 7.3.941
ffc55f2
Problem:    Stuff in if_py_both.h is ordered badly.
ffc55f2
Solution:   Reorder by type. (ZyX)
ffc55f2
Files:	    src/if_py_both.h, src/if_python.c
ffc55f2
ffc55f2
ffc55f2
*** ../vim-7.3.940/src/if_py_both.h	2013-05-12 19:30:27.000000000 +0200
ffc55f2
--- src/if_py_both.h	2013-05-12 19:36:38.000000000 +0200
ffc55f2
***************
ffc55f2
*** 7,13 ****
ffc55f2
   * See README.txt for an overview of the Vim source code.
ffc55f2
   */
ffc55f2
  /*
ffc55f2
!  * Python extensions by Paul Moore, David Leonard, Roland Puntaier.
ffc55f2
   *
ffc55f2
   * Common code for if_python.c and if_python3.c.
ffc55f2
   */
ffc55f2
--- 7,14 ----
ffc55f2
   * See README.txt for an overview of the Vim source code.
ffc55f2
   */
ffc55f2
  /*
ffc55f2
!  * Python extensions by Paul Moore, David Leonard, Roland Puntaier, Nikolay
ffc55f2
!  * Pavlov.
ffc55f2
   *
ffc55f2
   * Common code for if_python.c and if_python3.c.
ffc55f2
   */
ffc55f2
***************
ffc55f2
*** 22,27 ****
ffc55f2
--- 23,39 ----
ffc55f2
  # define ENC_OPT "latin1"
ffc55f2
  #endif
ffc55f2
  
ffc55f2
+ #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
ffc55f2
+ 
ffc55f2
+ #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
ffc55f2
+ #define INVALID_WINDOW_VALUE ((win_T *)(-1))
ffc55f2
+ 
ffc55f2
+ static int ConvertFromPyObject(PyObject *, typval_T *);
ffc55f2
+ static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
ffc55f2
+ 
ffc55f2
+ static PyInt RangeStart;
ffc55f2
+ static PyInt RangeEnd;
ffc55f2
+ 
ffc55f2
  /*
ffc55f2
   * obtain a lock on the Vim data structures
ffc55f2
   */
ffc55f2
***************
ffc55f2
*** 38,53 ****
ffc55f2
  {
ffc55f2
  }
ffc55f2
  
ffc55f2
! /* Output object definition
ffc55f2
   */
ffc55f2
  
ffc55f2
- static PyObject *OutputWrite(PyObject *, PyObject *);
ffc55f2
- static PyObject *OutputWritelines(PyObject *, PyObject *);
ffc55f2
- static PyObject *OutputFlush(PyObject *, PyObject *);
ffc55f2
- 
ffc55f2
  /* Function to write a line, points to either msg() or emsg(). */
ffc55f2
  typedef void (*writefn)(char_u *);
ffc55f2
! static void writer(writefn fn, char_u *str, PyInt n);
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
--- 50,62 ----
ffc55f2
  {
ffc55f2
  }
ffc55f2
  
ffc55f2
! /* Output buffer management
ffc55f2
   */
ffc55f2
  
ffc55f2
  /* Function to write a line, points to either msg() or emsg(). */
ffc55f2
  typedef void (*writefn)(char_u *);
ffc55f2
! 
ffc55f2
! static PyTypeObject OutputType;
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 56,76 ****
ffc55f2
      long error;
ffc55f2
  } OutputObject;
ffc55f2
  
ffc55f2
- static struct PyMethodDef OutputMethods[] = {
ffc55f2
-     /* name,	    function,		calling,    documentation */
ffc55f2
-     {"write",	    OutputWrite,	1,	    ""},
ffc55f2
-     {"writelines",  OutputWritelines,	1,	    ""},
ffc55f2
-     {"flush",	    OutputFlush,	1,	    ""},
ffc55f2
-     { NULL,	    NULL,		0,	    NULL}
ffc55f2
- };
ffc55f2
- 
ffc55f2
- #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
ffc55f2
- 
ffc55f2
- /*************/
ffc55f2
- 
ffc55f2
- /* Output buffer management
ffc55f2
-  */
ffc55f2
- 
ffc55f2
      static int
ffc55f2
  OutputSetattr(PyObject *self, char *name, PyObject *val)
ffc55f2
  {
ffc55f2
--- 65,70 ----
ffc55f2
***************
ffc55f2
*** 96,101 ****
ffc55f2
--- 90,145 ----
ffc55f2
      return -1;
ffc55f2
  }
ffc55f2
  
ffc55f2
+ /* Buffer IO, we write one whole line at a time. */
ffc55f2
+ static garray_T io_ga = {0, 0, 1, 80, NULL};
ffc55f2
+ static writefn old_fn = NULL;
ffc55f2
+ 
ffc55f2
+     static void
ffc55f2
+ PythonIO_Flush(void)
ffc55f2
+ {
ffc55f2
+     if (old_fn != NULL && io_ga.ga_len > 0)
ffc55f2
+     {
ffc55f2
+ 	((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL;
ffc55f2
+ 	old_fn((char_u *)io_ga.ga_data);
ffc55f2
+     }
ffc55f2
+     io_ga.ga_len = 0;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
+     static void
ffc55f2
+ writer(writefn fn, char_u *str, PyInt n)
ffc55f2
+ {
ffc55f2
+     char_u *ptr;
ffc55f2
+ 
ffc55f2
+     /* Flush when switching output function. */
ffc55f2
+     if (fn != old_fn)
ffc55f2
+ 	PythonIO_Flush();
ffc55f2
+     old_fn = fn;
ffc55f2
+ 
ffc55f2
+     /* Write each NL separated line.  Text after the last NL is kept for
ffc55f2
+      * writing later. */
ffc55f2
+     while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL)
ffc55f2
+     {
ffc55f2
+ 	PyInt len = ptr - str;
ffc55f2
+ 
ffc55f2
+ 	if (ga_grow(&io_ga, (int)(len + 1)) == FAIL)
ffc55f2
+ 	    break;
ffc55f2
+ 
ffc55f2
+ 	mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len);
ffc55f2
+ 	((char *)io_ga.ga_data)[io_ga.ga_len + len] = NUL;
ffc55f2
+ 	fn((char_u *)io_ga.ga_data);
ffc55f2
+ 	str = ptr + 1;
ffc55f2
+ 	n -= len + 1;
ffc55f2
+ 	io_ga.ga_len = 0;
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     /* Put the remaining text into io_ga for later printing. */
ffc55f2
+     if (n > 0 && ga_grow(&io_ga, (int)(n + 1)) == OK)
ffc55f2
+     {
ffc55f2
+ 	mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)n);
ffc55f2
+ 	io_ga.ga_len += (int)n;
ffc55f2
+     }
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
      static PyObject *
ffc55f2
  OutputWrite(PyObject *self, PyObject *args)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 172,231 ****
ffc55f2
      return Py_None;
ffc55f2
  }
ffc55f2
  
ffc55f2
- 
ffc55f2
- /* Buffer IO, we write one whole line at a time. */
ffc55f2
- static garray_T io_ga = {0, 0, 1, 80, NULL};
ffc55f2
- static writefn old_fn = NULL;
ffc55f2
- 
ffc55f2
-     static void
ffc55f2
- PythonIO_Flush(void)
ffc55f2
- {
ffc55f2
-     if (old_fn != NULL && io_ga.ga_len > 0)
ffc55f2
-     {
ffc55f2
- 	((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL;
ffc55f2
- 	old_fn((char_u *)io_ga.ga_data);
ffc55f2
-     }
ffc55f2
-     io_ga.ga_len = 0;
ffc55f2
- }
ffc55f2
- 
ffc55f2
-     static void
ffc55f2
- writer(writefn fn, char_u *str, PyInt n)
ffc55f2
- {
ffc55f2
-     char_u *ptr;
ffc55f2
- 
ffc55f2
-     /* Flush when switching output function. */
ffc55f2
-     if (fn != old_fn)
ffc55f2
- 	PythonIO_Flush();
ffc55f2
-     old_fn = fn;
ffc55f2
- 
ffc55f2
-     /* Write each NL separated line.  Text after the last NL is kept for
ffc55f2
-      * writing later. */
ffc55f2
-     while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL)
ffc55f2
-     {
ffc55f2
- 	PyInt len = ptr - str;
ffc55f2
- 
ffc55f2
- 	if (ga_grow(&io_ga, (int)(len + 1)) == FAIL)
ffc55f2
- 	    break;
ffc55f2
- 
ffc55f2
- 	mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len);
ffc55f2
- 	((char *)io_ga.ga_data)[io_ga.ga_len + len] = NUL;
ffc55f2
- 	fn((char_u *)io_ga.ga_data);
ffc55f2
- 	str = ptr + 1;
ffc55f2
- 	n -= len + 1;
ffc55f2
- 	io_ga.ga_len = 0;
ffc55f2
-     }
ffc55f2
- 
ffc55f2
-     /* Put the remaining text into io_ga for later printing. */
ffc55f2
-     if (n > 0 && ga_grow(&io_ga, (int)(n + 1)) == OK)
ffc55f2
-     {
ffc55f2
- 	mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)n);
ffc55f2
- 	io_ga.ga_len += (int)n;
ffc55f2
-     }
ffc55f2
- }
ffc55f2
- 
ffc55f2
  /***************/
ffc55f2
  
ffc55f2
! static PyTypeObject OutputType;
ffc55f2
  
ffc55f2
  static OutputObject Output =
ffc55f2
  {
ffc55f2
--- 216,230 ----
ffc55f2
      return Py_None;
ffc55f2
  }
ffc55f2
  
ffc55f2
  /***************/
ffc55f2
  
ffc55f2
! static struct PyMethodDef OutputMethods[] = {
ffc55f2
!     /* name,	    function,		calling,    documentation */
ffc55f2
!     {"write",	    OutputWrite,	1,	    ""},
ffc55f2
!     {"writelines",  OutputWritelines,	1,	    ""},
ffc55f2
!     {"flush",	    OutputFlush,	1,	    ""},
ffc55f2
!     { NULL,	    NULL,		0,	    NULL}
ffc55f2
! };
ffc55f2
  
ffc55f2
  static OutputObject Output =
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 281,286 ****
ffc55f2
--- 280,286 ----
ffc55f2
  
ffc55f2
  /* Vim module - Implementation
ffc55f2
   */
ffc55f2
+ 
ffc55f2
      static PyObject *
ffc55f2
  VimCommand(PyObject *self UNUSED, PyObject *args)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 530,555 ****
ffc55f2
      { NULL,	     NULL,		0,	    NULL }
ffc55f2
  };
ffc55f2
  
ffc55f2
- typedef struct
ffc55f2
- {
ffc55f2
-     PyObject_HEAD
ffc55f2
-     buf_T *buf;
ffc55f2
- } BufferObject;
ffc55f2
- 
ffc55f2
- #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
ffc55f2
- 
ffc55f2
  /*
ffc55f2
   * Buffer list object - Implementation
ffc55f2
   */
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
      PyObject_HEAD
ffc55f2
  } BufListObject;
ffc55f2
  
ffc55f2
- static PyTypeObject BufListType;
ffc55f2
- static PySequenceMethods WinListAsSeq;
ffc55f2
- 
ffc55f2
      static PyInt
ffc55f2
  BufListLength(PyObject *self UNUSED)
ffc55f2
  {
ffc55f2
--- 530,547 ----
ffc55f2
      { NULL,	     NULL,		0,	    NULL }
ffc55f2
  };
ffc55f2
  
ffc55f2
  /*
ffc55f2
   * Buffer list object - Implementation
ffc55f2
   */
ffc55f2
  
ffc55f2
+ static PyTypeObject BufListType;
ffc55f2
+ static PySequenceMethods BufListAsSeq;
ffc55f2
+ 
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
      PyObject_HEAD
ffc55f2
  } BufListObject;
ffc55f2
  
ffc55f2
      static PyInt
ffc55f2
  BufListLength(PyObject *self UNUSED)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 580,599 ****
ffc55f2
      return NULL;
ffc55f2
  }
ffc55f2
  
ffc55f2
- typedef struct
ffc55f2
- {
ffc55f2
-     PyObject_HEAD
ffc55f2
-     win_T	*win;
ffc55f2
- } WindowObject;
ffc55f2
- 
ffc55f2
- static struct PyMethodDef WindowMethods[] = {
ffc55f2
-     /* name,	    function,		calling,    documentation */
ffc55f2
-     { NULL,	    NULL,		0,	    NULL }
ffc55f2
- };
ffc55f2
- 
ffc55f2
- static int ConvertFromPyObject(PyObject *, typval_T *);
ffc55f2
- static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
ffc55f2
- 
ffc55f2
  typedef struct pylinkedlist_S {
ffc55f2
      struct pylinkedlist_S	*pll_next;
ffc55f2
      struct pylinkedlist_S	*pll_prev;
ffc55f2
--- 572,577 ----
ffc55f2
***************
ffc55f2
*** 655,670 ****
ffc55f2
      pylinkedlist_T	ref;
ffc55f2
  } DictionaryObject;
ffc55f2
  
ffc55f2
- static PyInt DictionaryAssItem(PyObject *, PyObject *, PyObject *);
ffc55f2
- static PyInt DictionaryLength(PyObject *);
ffc55f2
- static PyObject *DictionaryItem(PyObject *, PyObject *);
ffc55f2
- 
ffc55f2
- static PyMappingMethods DictionaryAsMapping = {
ffc55f2
-     (lenfunc)       DictionaryLength,
ffc55f2
-     (binaryfunc)    DictionaryItem,
ffc55f2
-     (objobjargproc) DictionaryAssItem,
ffc55f2
- };
ffc55f2
- 
ffc55f2
      static PyObject *
ffc55f2
  DictionaryNew(dict_T *dict)
ffc55f2
  {
ffc55f2
--- 633,638 ----
ffc55f2
***************
ffc55f2
*** 693,895 ****
ffc55f2
  }
ffc55f2
  
ffc55f2
      static int
ffc55f2
! pydict_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
  {
ffc55f2
!     dict_T	*d;
ffc55f2
!     char_u	*key;
ffc55f2
!     dictitem_T	*di;
ffc55f2
!     PyObject	*keyObject;
ffc55f2
!     PyObject	*valObject;
ffc55f2
!     Py_ssize_t	iter = 0;
ffc55f2
  
ffc55f2
!     d = dict_alloc();
ffc55f2
!     if (d == NULL)
ffc55f2
      {
ffc55f2
! 	PyErr_NoMemory();
ffc55f2
  	return -1;
ffc55f2
      }
ffc55f2
  
ffc55f2
!     tv->v_type = VAR_DICT;
ffc55f2
!     tv->vval.v_dict = d;
ffc55f2
! 
ffc55f2
!     while (PyDict_Next(obj, &iter, &keyObject, &valObject))
ffc55f2
      {
ffc55f2
! 	DICTKEY_DECL
ffc55f2
! 
ffc55f2
! 	if (keyObject == NULL)
ffc55f2
! 	    return -1;
ffc55f2
! 	if (valObject == NULL)
ffc55f2
! 	    return -1;
ffc55f2
! 
ffc55f2
! 	DICTKEY_GET_NOTEMPTY(-1)
ffc55f2
! 
ffc55f2
! 	di = dictitem_alloc(key);
ffc55f2
! 
ffc55f2
! 	DICTKEY_UNREF
ffc55f2
! 
ffc55f2
! 	if (di == NULL)
ffc55f2
! 	{
ffc55f2
! 	    PyErr_NoMemory();
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 	di->di_tv.v_lock = 0;
ffc55f2
! 
ffc55f2
! 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
ffc55f2
  	{
ffc55f2
! 	    vim_free(di);
ffc55f2
  	    return -1;
ffc55f2
  	}
ffc55f2
! 	if (dict_add(d, di) == FAIL)
ffc55f2
  	{
ffc55f2
! 	    vim_free(di);
ffc55f2
! 	    PyErr_SetVim(_("failed to add key to dictionary"));
ffc55f2
! 	    return -1;
ffc55f2
  	}
ffc55f2
      }
ffc55f2
-     return 0;
ffc55f2
  }
ffc55f2
  
ffc55f2
!     static int
ffc55f2
! pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
  {
ffc55f2
-     dict_T	*d;
ffc55f2
      char_u	*key;
ffc55f2
      dictitem_T	*di;
ffc55f2
!     PyObject	*list;
ffc55f2
!     PyObject	*litem;
ffc55f2
!     PyObject	*keyObject;
ffc55f2
!     PyObject	*valObject;
ffc55f2
!     Py_ssize_t	lsize;
ffc55f2
! 
ffc55f2
!     d = dict_alloc();
ffc55f2
!     if (d == NULL)
ffc55f2
!     {
ffc55f2
! 	PyErr_NoMemory();
ffc55f2
! 	return -1;
ffc55f2
!     }
ffc55f2
! 
ffc55f2
!     tv->v_type = VAR_DICT;
ffc55f2
!     tv->vval.v_dict = d;
ffc55f2
! 
ffc55f2
!     list = PyMapping_Items(obj);
ffc55f2
!     if (list == NULL)
ffc55f2
! 	return -1;
ffc55f2
!     lsize = PyList_Size(list);
ffc55f2
!     while (lsize--)
ffc55f2
!     {
ffc55f2
! 	DICTKEY_DECL
ffc55f2
! 
ffc55f2
! 	litem = PyList_GetItem(list, lsize);
ffc55f2
! 	if (litem == NULL)
ffc55f2
! 	{
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 
ffc55f2
! 	keyObject = PyTuple_GetItem(litem, 0);
ffc55f2
! 	if (keyObject == NULL)
ffc55f2
! 	{
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    Py_DECREF(litem);
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 
ffc55f2
! 	DICTKEY_GET_NOTEMPTY(-1)
ffc55f2
! 
ffc55f2
! 	valObject = PyTuple_GetItem(litem, 1);
ffc55f2
! 	if (valObject == NULL)
ffc55f2
! 	{
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    Py_DECREF(litem);
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 
ffc55f2
! 	di = dictitem_alloc(key);
ffc55f2
! 
ffc55f2
! 	DICTKEY_UNREF
ffc55f2
! 
ffc55f2
! 	if (di == NULL)
ffc55f2
! 	{
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    Py_DECREF(litem);
ffc55f2
! 	    PyErr_NoMemory();
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 	di->di_tv.v_lock = 0;
ffc55f2
! 
ffc55f2
! 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
ffc55f2
! 	{
ffc55f2
! 	    vim_free(di);
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    Py_DECREF(litem);
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 	if (dict_add(d, di) == FAIL)
ffc55f2
! 	{
ffc55f2
! 	    vim_free(di);
ffc55f2
! 	    Py_DECREF(list);
ffc55f2
! 	    Py_DECREF(litem);
ffc55f2
! 	    PyErr_SetVim(_("failed to add key to dictionary"));
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 	Py_DECREF(litem);
ffc55f2
!     }
ffc55f2
!     Py_DECREF(list);
ffc55f2
!     return 0;
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static int
ffc55f2
! DictionarySetattr(PyObject *self, char *name, PyObject *val)
ffc55f2
! {
ffc55f2
!     DictionaryObject *this = (DictionaryObject *)(self);
ffc55f2
! 
ffc55f2
!     if (val == NULL)
ffc55f2
!     {
ffc55f2
! 	PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
ffc55f2
! 	return -1;
ffc55f2
!     }
ffc55f2
! 
ffc55f2
!     if (strcmp(name, "locked") == 0)
ffc55f2
!     {
ffc55f2
! 	if (this->dict->dv_lock == VAR_FIXED)
ffc55f2
! 	{
ffc55f2
! 	    PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
ffc55f2
! 	    return -1;
ffc55f2
! 	}
ffc55f2
! 	else
ffc55f2
! 	{
ffc55f2
! 	    if (!PyBool_Check(val))
ffc55f2
! 	    {
ffc55f2
! 		PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
ffc55f2
! 		return -1;
ffc55f2
! 	    }
ffc55f2
! 
ffc55f2
! 	    if (val == Py_True)
ffc55f2
! 		this->dict->dv_lock = VAR_LOCKED;
ffc55f2
! 	    else
ffc55f2
! 		this->dict->dv_lock = 0;
ffc55f2
! 	}
ffc55f2
! 	return 0;
ffc55f2
!     }
ffc55f2
!     else
ffc55f2
!     {
ffc55f2
! 	PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
ffc55f2
! 	return -1;
ffc55f2
!     }
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyInt
ffc55f2
! DictionaryLength(PyObject *self)
ffc55f2
! {
ffc55f2
!     return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! DictionaryItem(PyObject *self, PyObject *keyObject)
ffc55f2
! {
ffc55f2
!     char_u	*key;
ffc55f2
!     dictitem_T	*di;
ffc55f2
!     DICTKEY_DECL
ffc55f2
  
ffc55f2
      DICTKEY_GET_NOTEMPTY(NULL)
ffc55f2
  
ffc55f2
--- 661,717 ----
ffc55f2
  }
ffc55f2
  
ffc55f2
      static int
ffc55f2
! DictionarySetattr(PyObject *self, char *name, PyObject *val)
ffc55f2
  {
ffc55f2
!     DictionaryObject *this = (DictionaryObject *)(self);
ffc55f2
  
ffc55f2
!     if (val == NULL)
ffc55f2
      {
ffc55f2
! 	PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
ffc55f2
  	return -1;
ffc55f2
      }
ffc55f2
  
ffc55f2
!     if (strcmp(name, "locked") == 0)
ffc55f2
      {
ffc55f2
! 	if (this->dict->dv_lock == VAR_FIXED)
ffc55f2
  	{
ffc55f2
! 	    PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
ffc55f2
  	    return -1;
ffc55f2
  	}
ffc55f2
! 	else
ffc55f2
  	{
ffc55f2
! 	    if (!PyBool_Check(val))
ffc55f2
! 	    {
ffc55f2
! 		PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
ffc55f2
! 		return -1;
ffc55f2
! 	    }
ffc55f2
! 
ffc55f2
! 	    if (val == Py_True)
ffc55f2
! 		this->dict->dv_lock = VAR_LOCKED;
ffc55f2
! 	    else
ffc55f2
! 		this->dict->dv_lock = 0;
ffc55f2
  	}
ffc55f2
+ 	return 0;
ffc55f2
+     }
ffc55f2
+     else
ffc55f2
+     {
ffc55f2
+ 	PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
ffc55f2
+ 	return -1;
ffc55f2
      }
ffc55f2
  }
ffc55f2
  
ffc55f2
!     static PyInt
ffc55f2
! DictionaryLength(PyObject *self)
ffc55f2
! {
ffc55f2
!     return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! DictionaryItem(PyObject *self, PyObject *keyObject)
ffc55f2
  {
ffc55f2
      char_u	*key;
ffc55f2
      dictitem_T	*di;
ffc55f2
!     DICTKEY_DECL
ffc55f2
  
ffc55f2
      DICTKEY_GET_NOTEMPTY(NULL)
ffc55f2
  
ffc55f2
***************
ffc55f2
*** 993,998 ****
ffc55f2
--- 815,826 ----
ffc55f2
      return r;
ffc55f2
  }
ffc55f2
  
ffc55f2
+ static PyMappingMethods DictionaryAsMapping = {
ffc55f2
+     (lenfunc)       DictionaryLength,
ffc55f2
+     (binaryfunc)    DictionaryItem,
ffc55f2
+     (objobjargproc) DictionaryAssItem,
ffc55f2
+ };
ffc55f2
+ 
ffc55f2
  static struct PyMethodDef DictionaryMethods[] = {
ffc55f2
      {"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
ffc55f2
      { NULL,	    NULL,		0,	    NULL }
ffc55f2
***************
ffc55f2
*** 1065,1136 ****
ffc55f2
      return 0;
ffc55f2
  }
ffc55f2
  
ffc55f2
-     static int
ffc55f2
- pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
- {
ffc55f2
-     list_T	*l;
ffc55f2
- 
ffc55f2
-     l = list_alloc();
ffc55f2
-     if (l == NULL)
ffc55f2
-     {
ffc55f2
- 	PyErr_NoMemory();
ffc55f2
- 	return -1;
ffc55f2
-     }
ffc55f2
- 
ffc55f2
-     tv->v_type = VAR_LIST;
ffc55f2
-     tv->vval.v_list = l;
ffc55f2
- 
ffc55f2
-     if (list_py_concat(l, obj, lookupDict) == -1)
ffc55f2
- 	return -1;
ffc55f2
- 
ffc55f2
-     return 0;
ffc55f2
- }
ffc55f2
- 
ffc55f2
-     static int
ffc55f2
- pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
- {
ffc55f2
-     PyObject	*iterator = PyObject_GetIter(obj);
ffc55f2
-     PyObject	*item;
ffc55f2
-     list_T	*l;
ffc55f2
-     listitem_T	*li;
ffc55f2
- 
ffc55f2
-     l = list_alloc();
ffc55f2
- 
ffc55f2
-     if (l == NULL)
ffc55f2
-     {
ffc55f2
- 	PyErr_NoMemory();
ffc55f2
- 	return -1;
ffc55f2
-     }
ffc55f2
- 
ffc55f2
-     tv->vval.v_list = l;
ffc55f2
-     tv->v_type = VAR_LIST;
ffc55f2
- 
ffc55f2
- 
ffc55f2
-     if (iterator == NULL)
ffc55f2
- 	return -1;
ffc55f2
- 
ffc55f2
-     while ((item = PyIter_Next(obj)))
ffc55f2
-     {
ffc55f2
- 	li = listitem_alloc();
ffc55f2
- 	if (li == NULL)
ffc55f2
- 	{
ffc55f2
- 	    PyErr_NoMemory();
ffc55f2
- 	    return -1;
ffc55f2
- 	}
ffc55f2
- 	li->li_tv.v_lock = 0;
ffc55f2
- 
ffc55f2
- 	if (_ConvertFromPyObject(item, &li->li_tv, lookupDict) == -1)
ffc55f2
- 	    return -1;
ffc55f2
- 
ffc55f2
- 	list_append(l, li);
ffc55f2
- 
ffc55f2
- 	Py_DECREF(item);
ffc55f2
-     }
ffc55f2
- 
ffc55f2
-     Py_DECREF(iterator);
ffc55f2
-     return 0;
ffc55f2
- }
ffc55f2
- 
ffc55f2
      static PyInt
ffc55f2
  ListLength(PyObject *self)
ffc55f2
  {
ffc55f2
--- 893,898 ----
ffc55f2
***************
ffc55f2
*** 1768,1774 ****
ffc55f2
      (objobjargproc) OptionsAssItem,
ffc55f2
  };
ffc55f2
  
ffc55f2
! #define INVALID_WINDOW_VALUE ((win_T *)(-1))
ffc55f2
  
ffc55f2
      static int
ffc55f2
  CheckWindow(WindowObject *this)
ffc55f2
--- 1530,1547 ----
ffc55f2
      (objobjargproc) OptionsAssItem,
ffc55f2
  };
ffc55f2
  
ffc55f2
! /* Window object
ffc55f2
!  */
ffc55f2
! 
ffc55f2
! typedef struct
ffc55f2
! {
ffc55f2
!     PyObject_HEAD
ffc55f2
!     win_T	*win;
ffc55f2
! } WindowObject;
ffc55f2
! 
ffc55f2
! static int WindowSetattr(PyObject *, char *, PyObject *);
ffc55f2
! static PyObject *WindowRepr(PyObject *);
ffc55f2
! static PyTypeObject WindowType;
ffc55f2
  
ffc55f2
      static int
ffc55f2
  CheckWindow(WindowObject *this)
ffc55f2
***************
ffc55f2
*** 1782,1794 ****
ffc55f2
      return 0;
ffc55f2
  }
ffc55f2
  
ffc55f2
- /* Window object
ffc55f2
-  */
ffc55f2
- 
ffc55f2
- static int WindowSetattr(PyObject *, char *, PyObject *);
ffc55f2
- static PyObject *WindowRepr(PyObject *);
ffc55f2
- static PyTypeObject WindowType;
ffc55f2
- 
ffc55f2
      static PyObject *
ffc55f2
  WindowNew(win_T *win)
ffc55f2
  {
ffc55f2
--- 1555,1560 ----
ffc55f2
***************
ffc55f2
*** 1803,1809 ****
ffc55f2
       * to an invalid value. We trap all uses of a window
ffc55f2
       * object, and reject them if the win_T* field is invalid.
ffc55f2
       *
ffc55f2
!      * Python2 and Python3 get different fields and different objects: 
ffc55f2
       * w_python_ref and w_python3_ref fields respectively.
ffc55f2
       */
ffc55f2
  
ffc55f2
--- 1569,1575 ----
ffc55f2
       * to an invalid value. We trap all uses of a window
ffc55f2
       * object, and reject them if the win_T* field is invalid.
ffc55f2
       *
ffc55f2
!      * Python2 and Python3 get different fields and different objects:
ffc55f2
       * w_python_ref and w_python3_ref fields respectively.
ffc55f2
       */
ffc55f2
  
ffc55f2
***************
ffc55f2
*** 1826,1831 ****
ffc55f2
--- 1592,1608 ----
ffc55f2
      return (PyObject *)(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
+     static void
ffc55f2
+ WindowDestructor(PyObject *self)
ffc55f2
+ {
ffc55f2
+     WindowObject *this = (WindowObject *)(self);
ffc55f2
+ 
ffc55f2
+     if (this->win && this->win != INVALID_WINDOW_VALUE)
ffc55f2
+ 	WIN_PYTHON_REF(this->win) = NULL;
ffc55f2
+ 
ffc55f2
+     DESTRUCTOR_FINISH(self);
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
      static PyObject *
ffc55f2
  WindowAttr(WindowObject *this, char *name)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 1863,1879 ****
ffc55f2
  	return NULL;
ffc55f2
  }
ffc55f2
  
ffc55f2
-     static void
ffc55f2
- WindowDestructor(PyObject *self)
ffc55f2
- {
ffc55f2
-     WindowObject *this = (WindowObject *)(self);
ffc55f2
- 
ffc55f2
-     if (this->win && this->win != INVALID_WINDOW_VALUE)
ffc55f2
- 	WIN_PYTHON_REF(this->win) = NULL;
ffc55f2
- 
ffc55f2
-     DESTRUCTOR_FINISH(self);
ffc55f2
- }
ffc55f2
- 
ffc55f2
      static int
ffc55f2
  WindowSetattr(PyObject *self, char *name, PyObject *val)
ffc55f2
  {
ffc55f2
--- 1640,1645 ----
ffc55f2
***************
ffc55f2
*** 1994,2011 ****
ffc55f2
      }
ffc55f2
  }
ffc55f2
  
ffc55f2
  /*
ffc55f2
!  * Window list object - Implementation
ffc55f2
   */
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
      PyObject_HEAD
ffc55f2
  } WinListObject;
ffc55f2
  
ffc55f2
- static PyTypeObject WinListType;
ffc55f2
- static PySequenceMethods BufListAsSeq;
ffc55f2
- 
ffc55f2
      static PyInt
ffc55f2
  WinListLength(PyObject *self UNUSED)
ffc55f2
  {
ffc55f2
--- 1760,1782 ----
ffc55f2
      }
ffc55f2
  }
ffc55f2
  
ffc55f2
+ static struct PyMethodDef WindowMethods[] = {
ffc55f2
+     /* name,	    function,		calling,    documentation */
ffc55f2
+     { NULL,	    NULL,		0,	    NULL }
ffc55f2
+ };
ffc55f2
+ 
ffc55f2
  /*
ffc55f2
!  * Window list object
ffc55f2
   */
ffc55f2
  
ffc55f2
+ static PyTypeObject WinListType;
ffc55f2
+ static PySequenceMethods WinListAsSeq;
ffc55f2
+ 
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
      PyObject_HEAD
ffc55f2
  } WinListObject;
ffc55f2
  
ffc55f2
      static PyInt
ffc55f2
  WinListLength(PyObject *self UNUSED)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 2596,2602 ****
ffc55f2
   * -------------------------------------------
ffc55f2
   */
ffc55f2
  
ffc55f2
!     static int
ffc55f2
  CheckBuffer(BufferObject *this)
ffc55f2
  {
ffc55f2
      if (this->buf == INVALID_BUFFER_VALUE)
ffc55f2
--- 2367,2379 ----
ffc55f2
   * -------------------------------------------
ffc55f2
   */
ffc55f2
  
ffc55f2
! typedef struct
ffc55f2
! {
ffc55f2
!     PyObject_HEAD
ffc55f2
!     buf_T *buf;
ffc55f2
! } BufferObject;
ffc55f2
! 
ffc55f2
!     static int
ffc55f2
  CheckBuffer(BufferObject *this)
ffc55f2
  {
ffc55f2
      if (this->buf == INVALID_BUFFER_VALUE)
ffc55f2
***************
ffc55f2
*** 2737,2746 ****
ffc55f2
      return Py_None;
ffc55f2
  }
ffc55f2
  
ffc55f2
! /* Range object - Definitions
ffc55f2
   */
ffc55f2
  
ffc55f2
  static PyTypeObject RangeType;
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
--- 2514,2525 ----
ffc55f2
      return Py_None;
ffc55f2
  }
ffc55f2
  
ffc55f2
! /* Range object
ffc55f2
   */
ffc55f2
  
ffc55f2
  static PyTypeObject RangeType;
ffc55f2
+ static PySequenceMethods RangeAsSeq;
ffc55f2
+ static PyMappingMethods RangeAsMapping;
ffc55f2
  
ffc55f2
  typedef struct
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 2750,2759 ****
ffc55f2
      PyInt end;
ffc55f2
  } RangeObject;
ffc55f2
  
ffc55f2
- static void RangeDestructor(PyObject *);
ffc55f2
- static PySequenceMethods RangeAsSeq;
ffc55f2
- static PyMappingMethods RangeAsMapping;
ffc55f2
- 
ffc55f2
      static PyObject *
ffc55f2
  RangeNew(buf_T *buf, PyInt start, PyInt end)
ffc55f2
  {
ffc55f2
--- 2529,2534 ----
ffc55f2
***************
ffc55f2
*** 2785,2806 ****
ffc55f2
      DESTRUCTOR_FINISH(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
! static PyTypeObject BufferType;
ffc55f2
! static PyObject *BufferRepr(PyObject *);
ffc55f2
! static PySequenceMethods BufferAsSeq;
ffc55f2
! static PyMappingMethods BufferAsMapping;
ffc55f2
  
ffc55f2
!     static void
ffc55f2
! BufferDestructor(PyObject *self)
ffc55f2
  {
ffc55f2
!     BufferObject *this = (BufferObject *)(self);
ffc55f2
  
ffc55f2
!     if (this->buf && this->buf != INVALID_BUFFER_VALUE)
ffc55f2
! 	BUF_PYTHON_REF(this->buf) = NULL;
ffc55f2
  
ffc55f2
!     DESTRUCTOR_FINISH(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
      static PyObject *
ffc55f2
  BufferNew(buf_T *buf)
ffc55f2
  {
ffc55f2
--- 2560,2642 ----
ffc55f2
      DESTRUCTOR_FINISH(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
!     static PyInt
ffc55f2
! RangeLength(PyObject *self)
ffc55f2
! {
ffc55f2
!     /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
ffc55f2
!     if (CheckBuffer(((RangeObject *)(self))->buf))
ffc55f2
! 	return -1; /* ??? */
ffc55f2
  
ffc55f2
!     return (((RangeObject *)(self))->end - ((RangeObject *)(self))->start + 1);
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! RangeItem(PyObject *self, PyInt n)
ffc55f2
  {
ffc55f2
!     return RBItem(((RangeObject *)(self))->buf, n,
ffc55f2
! 		  ((RangeObject *)(self))->start,
ffc55f2
! 		  ((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
  
ffc55f2
!     static PyObject *
ffc55f2
! RangeSlice(PyObject *self, PyInt lo, PyInt hi)
ffc55f2
! {
ffc55f2
!     return RBSlice(((RangeObject *)(self))->buf, lo, hi,
ffc55f2
! 		   ((RangeObject *)(self))->start,
ffc55f2
! 		   ((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
  
ffc55f2
!     static PyObject *
ffc55f2
! RangeAppend(PyObject *self, PyObject *args)
ffc55f2
! {
ffc55f2
!     return RBAppend(((RangeObject *)(self))->buf, args,
ffc55f2
! 		    ((RangeObject *)(self))->start,
ffc55f2
! 		    ((RangeObject *)(self))->end,
ffc55f2
! 		    &((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! RangeRepr(PyObject *self)
ffc55f2
! {
ffc55f2
!     static char repr[100];
ffc55f2
!     RangeObject *this = (RangeObject *)(self);
ffc55f2
! 
ffc55f2
!     if (this->buf->buf == INVALID_BUFFER_VALUE)
ffc55f2
!     {
ffc55f2
! 	vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>",
ffc55f2
! 								      (self));
ffc55f2
! 	return PyString_FromString(repr);
ffc55f2
!     }
ffc55f2
!     else
ffc55f2
!     {
ffc55f2
! 	char *name = (char *)this->buf->buf->b_fname;
ffc55f2
! 	int len;
ffc55f2
! 
ffc55f2
! 	if (name == NULL)
ffc55f2
! 	    name = "";
ffc55f2
! 	len = (int)strlen(name);
ffc55f2
! 
ffc55f2
! 	if (len > 45)
ffc55f2
! 	    name = name + (45 - len);
ffc55f2
! 
ffc55f2
! 	vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
ffc55f2
! 		len > 45 ? "..." : "", name,
ffc55f2
! 		this->start, this->end);
ffc55f2
! 
ffc55f2
! 	return PyString_FromString(repr);
ffc55f2
!     }
ffc55f2
  }
ffc55f2
  
ffc55f2
+ static struct PyMethodDef RangeMethods[] = {
ffc55f2
+     /* name,	    function,		calling,    documentation */
ffc55f2
+     {"append",	    RangeAppend,	1,	    "Append data to the Vim range" },
ffc55f2
+     { NULL,	    NULL,		0,	    NULL }
ffc55f2
+ };
ffc55f2
+ 
ffc55f2
+ static PyTypeObject BufferType;
ffc55f2
+ static PySequenceMethods BufferAsSeq;
ffc55f2
+ static PyMappingMethods BufferAsMapping;
ffc55f2
+ 
ffc55f2
      static PyObject *
ffc55f2
  BufferNew(buf_T *buf)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 2817,2823 ****
ffc55f2
       * set the buf_T * value to an invalid value (-1?), which
ffc55f2
       * means we need checks in all access functions... Bah.
ffc55f2
       *
ffc55f2
!      * Python2 and Python3 get different fields and different objects: 
ffc55f2
       * b_python_ref and b_python3_ref fields respectively.
ffc55f2
       */
ffc55f2
  
ffc55f2
--- 2653,2659 ----
ffc55f2
       * set the buf_T * value to an invalid value (-1?), which
ffc55f2
       * means we need checks in all access functions... Bah.
ffc55f2
       *
ffc55f2
!      * Python2 and Python3 get different fields and different objects:
ffc55f2
       * b_python_ref and b_python3_ref fields respectively.
ffc55f2
       */
ffc55f2
  
ffc55f2
***************
ffc55f2
*** 2840,2861 ****
ffc55f2
      return (PyObject *)(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
!     static PyObject *
ffc55f2
! BufferAttr(BufferObject *this, char *name)
ffc55f2
  {
ffc55f2
!     if (strcmp(name, "name") == 0)
ffc55f2
! 	return Py_BuildValue("s", this->buf->b_ffname);
ffc55f2
!     else if (strcmp(name, "number") == 0)
ffc55f2
! 	return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum);
ffc55f2
!     else if (strcmp(name, "vars") == 0)
ffc55f2
! 	return DictionaryNew(this->buf->b_vars);
ffc55f2
!     else if (strcmp(name, "options") == 0)
ffc55f2
! 	return OptionsNew(SREQ_BUF, this->buf, (checkfun) CheckBuffer,
ffc55f2
! 			(PyObject *) this);
ffc55f2
!     else if (strcmp(name,"__members__") == 0)
ffc55f2
! 	return Py_BuildValue("[ssss]", "name", "number", "vars", "options");
ffc55f2
!     else
ffc55f2
! 	return NULL;
ffc55f2
  }
ffc55f2
  
ffc55f2
      static PyInt
ffc55f2
--- 2676,2690 ----
ffc55f2
      return (PyObject *)(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
!     static void
ffc55f2
! BufferDestructor(PyObject *self)
ffc55f2
  {
ffc55f2
!     BufferObject *this = (BufferObject *)(self);
ffc55f2
! 
ffc55f2
!     if (this->buf && this->buf != INVALID_BUFFER_VALUE)
ffc55f2
! 	BUF_PYTHON_REF(this->buf) = NULL;
ffc55f2
! 
ffc55f2
!     DESTRUCTOR_FINISH(self);
ffc55f2
  }
ffc55f2
  
ffc55f2
      static PyInt
ffc55f2
***************
ffc55f2
*** 2883,2888 ****
ffc55f2
--- 2712,2735 ----
ffc55f2
  }
ffc55f2
  
ffc55f2
      static PyObject *
ffc55f2
+ BufferAttr(BufferObject *this, char *name)
ffc55f2
+ {
ffc55f2
+     if (strcmp(name, "name") == 0)
ffc55f2
+ 	return Py_BuildValue("s", this->buf->b_ffname);
ffc55f2
+     else if (strcmp(name, "number") == 0)
ffc55f2
+ 	return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum);
ffc55f2
+     else if (strcmp(name, "vars") == 0)
ffc55f2
+ 	return DictionaryNew(this->buf->b_vars);
ffc55f2
+     else if (strcmp(name, "options") == 0)
ffc55f2
+ 	return OptionsNew(SREQ_BUF, this->buf, (checkfun) CheckBuffer,
ffc55f2
+ 			(PyObject *) this);
ffc55f2
+     else if (strcmp(name,"__members__") == 0)
ffc55f2
+ 	return Py_BuildValue("[ssss]", "name", "number", "vars", "options");
ffc55f2
+     else
ffc55f2
+ 	return NULL;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
+     static PyObject *
ffc55f2
  BufferAppend(PyObject *self, PyObject *args)
ffc55f2
  {
ffc55f2
      return RBAppend((BufferObject *)(self), args, 1,
ffc55f2
***************
ffc55f2
*** 2985,3073 ****
ffc55f2
      { NULL,	    NULL,		0,	    NULL }
ffc55f2
  };
ffc55f2
  
ffc55f2
!     static PyObject *
ffc55f2
! RangeAppend(PyObject *self, PyObject *args)
ffc55f2
! {
ffc55f2
!     return RBAppend(((RangeObject *)(self))->buf, args,
ffc55f2
! 		    ((RangeObject *)(self))->start,
ffc55f2
! 		    ((RangeObject *)(self))->end,
ffc55f2
! 		    &((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyInt
ffc55f2
! RangeLength(PyObject *self)
ffc55f2
! {
ffc55f2
!     /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
ffc55f2
!     if (CheckBuffer(((RangeObject *)(self))->buf))
ffc55f2
! 	return -1; /* ??? */
ffc55f2
! 
ffc55f2
!     return (((RangeObject *)(self))->end - ((RangeObject *)(self))->start + 1);
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! RangeItem(PyObject *self, PyInt n)
ffc55f2
! {
ffc55f2
!     return RBItem(((RangeObject *)(self))->buf, n,
ffc55f2
! 		  ((RangeObject *)(self))->start,
ffc55f2
! 		  ((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! RangeRepr(PyObject *self)
ffc55f2
! {
ffc55f2
!     static char repr[100];
ffc55f2
!     RangeObject *this = (RangeObject *)(self);
ffc55f2
! 
ffc55f2
!     if (this->buf->buf == INVALID_BUFFER_VALUE)
ffc55f2
!     {
ffc55f2
! 	vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>",
ffc55f2
! 								      (self));
ffc55f2
! 	return PyString_FromString(repr);
ffc55f2
!     }
ffc55f2
!     else
ffc55f2
!     {
ffc55f2
! 	char *name = (char *)this->buf->buf->b_fname;
ffc55f2
! 	int len;
ffc55f2
! 
ffc55f2
! 	if (name == NULL)
ffc55f2
! 	    name = "";
ffc55f2
! 	len = (int)strlen(name);
ffc55f2
! 
ffc55f2
! 	if (len > 45)
ffc55f2
! 	    name = name + (45 - len);
ffc55f2
! 
ffc55f2
! 	vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
ffc55f2
! 		len > 45 ? "..." : "", name,
ffc55f2
! 		this->start, this->end);
ffc55f2
! 
ffc55f2
! 	return PyString_FromString(repr);
ffc55f2
!     }
ffc55f2
! }
ffc55f2
! 
ffc55f2
!     static PyObject *
ffc55f2
! RangeSlice(PyObject *self, PyInt lo, PyInt hi)
ffc55f2
! {
ffc55f2
!     return RBSlice(((RangeObject *)(self))->buf, lo, hi,
ffc55f2
! 		   ((RangeObject *)(self))->start,
ffc55f2
! 		   ((RangeObject *)(self))->end);
ffc55f2
! }
ffc55f2
! 
ffc55f2
! /*
ffc55f2
!  * Line range object - Definitions
ffc55f2
!  */
ffc55f2
! 
ffc55f2
! static struct PyMethodDef RangeMethods[] = {
ffc55f2
!     /* name,	    function,		calling,    documentation */
ffc55f2
!     {"append",	    RangeAppend,	1,	    "Append data to the Vim range" },
ffc55f2
!     { NULL,	    NULL,		0,	    NULL }
ffc55f2
! };
ffc55f2
! 
ffc55f2
! /* Current items object - Implementation
ffc55f2
   */
ffc55f2
  
ffc55f2
- static PyInt RangeStart;
ffc55f2
- static PyInt RangeEnd;
ffc55f2
- 
ffc55f2
      static PyObject *
ffc55f2
  CurrentGetattr(PyObject *self UNUSED, char *name)
ffc55f2
  {
ffc55f2
--- 2832,2840 ----
ffc55f2
      { NULL,	    NULL,		0,	    NULL }
ffc55f2
  };
ffc55f2
  
ffc55f2
! /* Current items object
ffc55f2
   */
ffc55f2
  
ffc55f2
      static PyObject *
ffc55f2
  CurrentGetattr(PyObject *self UNUSED, char *name)
ffc55f2
  {
ffc55f2
***************
ffc55f2
*** 3147,3152 ****
ffc55f2
--- 2914,3131 ----
ffc55f2
      return 0;
ffc55f2
  }
ffc55f2
  
ffc55f2
+     static int
ffc55f2
+ pydict_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
+ {
ffc55f2
+     dict_T	*d;
ffc55f2
+     char_u	*key;
ffc55f2
+     dictitem_T	*di;
ffc55f2
+     PyObject	*keyObject;
ffc55f2
+     PyObject	*valObject;
ffc55f2
+     Py_ssize_t	iter = 0;
ffc55f2
+ 
ffc55f2
+     d = dict_alloc();
ffc55f2
+     if (d == NULL)
ffc55f2
+     {
ffc55f2
+ 	PyErr_NoMemory();
ffc55f2
+ 	return -1;
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     tv->v_type = VAR_DICT;
ffc55f2
+     tv->vval.v_dict = d;
ffc55f2
+ 
ffc55f2
+     while (PyDict_Next(obj, &iter, &keyObject, &valObject))
ffc55f2
+     {
ffc55f2
+ 	DICTKEY_DECL
ffc55f2
+ 
ffc55f2
+ 	if (keyObject == NULL)
ffc55f2
+ 	    return -1;
ffc55f2
+ 	if (valObject == NULL)
ffc55f2
+ 	    return -1;
ffc55f2
+ 
ffc55f2
+ 	DICTKEY_GET_NOTEMPTY(-1)
ffc55f2
+ 
ffc55f2
+ 	di = dictitem_alloc(key);
ffc55f2
+ 
ffc55f2
+ 	DICTKEY_UNREF
ffc55f2
+ 
ffc55f2
+ 	if (di == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    PyErr_NoMemory();
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	di->di_tv.v_lock = 0;
ffc55f2
+ 
ffc55f2
+ 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
ffc55f2
+ 	{
ffc55f2
+ 	    vim_free(di);
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	if (dict_add(d, di) == FAIL)
ffc55f2
+ 	{
ffc55f2
+ 	    vim_free(di);
ffc55f2
+ 	    PyErr_SetVim(_("failed to add key to dictionary"));
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+     }
ffc55f2
+     return 0;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
+     static int
ffc55f2
+ pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
+ {
ffc55f2
+     dict_T	*d;
ffc55f2
+     char_u	*key;
ffc55f2
+     dictitem_T	*di;
ffc55f2
+     PyObject	*list;
ffc55f2
+     PyObject	*litem;
ffc55f2
+     PyObject	*keyObject;
ffc55f2
+     PyObject	*valObject;
ffc55f2
+     Py_ssize_t	lsize;
ffc55f2
+ 
ffc55f2
+     d = dict_alloc();
ffc55f2
+     if (d == NULL)
ffc55f2
+     {
ffc55f2
+ 	PyErr_NoMemory();
ffc55f2
+ 	return -1;
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     tv->v_type = VAR_DICT;
ffc55f2
+     tv->vval.v_dict = d;
ffc55f2
+ 
ffc55f2
+     list = PyMapping_Items(obj);
ffc55f2
+     if (list == NULL)
ffc55f2
+ 	return -1;
ffc55f2
+     lsize = PyList_Size(list);
ffc55f2
+     while (lsize--)
ffc55f2
+     {
ffc55f2
+ 	DICTKEY_DECL
ffc55f2
+ 
ffc55f2
+ 	litem = PyList_GetItem(list, lsize);
ffc55f2
+ 	if (litem == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 
ffc55f2
+ 	keyObject = PyTuple_GetItem(litem, 0);
ffc55f2
+ 	if (keyObject == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    Py_DECREF(litem);
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 
ffc55f2
+ 	DICTKEY_GET_NOTEMPTY(-1)
ffc55f2
+ 
ffc55f2
+ 	valObject = PyTuple_GetItem(litem, 1);
ffc55f2
+ 	if (valObject == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    Py_DECREF(litem);
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 
ffc55f2
+ 	di = dictitem_alloc(key);
ffc55f2
+ 
ffc55f2
+ 	DICTKEY_UNREF
ffc55f2
+ 
ffc55f2
+ 	if (di == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    Py_DECREF(litem);
ffc55f2
+ 	    PyErr_NoMemory();
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	di->di_tv.v_lock = 0;
ffc55f2
+ 
ffc55f2
+ 	if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
ffc55f2
+ 	{
ffc55f2
+ 	    vim_free(di);
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    Py_DECREF(litem);
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	if (dict_add(d, di) == FAIL)
ffc55f2
+ 	{
ffc55f2
+ 	    vim_free(di);
ffc55f2
+ 	    Py_DECREF(list);
ffc55f2
+ 	    Py_DECREF(litem);
ffc55f2
+ 	    PyErr_SetVim(_("failed to add key to dictionary"));
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	Py_DECREF(litem);
ffc55f2
+     }
ffc55f2
+     Py_DECREF(list);
ffc55f2
+     return 0;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
+     static int
ffc55f2
+ pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
+ {
ffc55f2
+     list_T	*l;
ffc55f2
+ 
ffc55f2
+     l = list_alloc();
ffc55f2
+     if (l == NULL)
ffc55f2
+     {
ffc55f2
+ 	PyErr_NoMemory();
ffc55f2
+ 	return -1;
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     tv->v_type = VAR_LIST;
ffc55f2
+     tv->vval.v_list = l;
ffc55f2
+ 
ffc55f2
+     if (list_py_concat(l, obj, lookupDict) == -1)
ffc55f2
+ 	return -1;
ffc55f2
+ 
ffc55f2
+     return 0;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
+     static int
ffc55f2
+ pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
ffc55f2
+ {
ffc55f2
+     PyObject	*iterator = PyObject_GetIter(obj);
ffc55f2
+     PyObject	*item;
ffc55f2
+     list_T	*l;
ffc55f2
+     listitem_T	*li;
ffc55f2
+ 
ffc55f2
+     l = list_alloc();
ffc55f2
+ 
ffc55f2
+     if (l == NULL)
ffc55f2
+     {
ffc55f2
+ 	PyErr_NoMemory();
ffc55f2
+ 	return -1;
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     tv->vval.v_list = l;
ffc55f2
+     tv->v_type = VAR_LIST;
ffc55f2
+ 
ffc55f2
+ 
ffc55f2
+     if (iterator == NULL)
ffc55f2
+ 	return -1;
ffc55f2
+ 
ffc55f2
+     while ((item = PyIter_Next(obj)))
ffc55f2
+     {
ffc55f2
+ 	li = listitem_alloc();
ffc55f2
+ 	if (li == NULL)
ffc55f2
+ 	{
ffc55f2
+ 	    PyErr_NoMemory();
ffc55f2
+ 	    return -1;
ffc55f2
+ 	}
ffc55f2
+ 	li->li_tv.v_lock = 0;
ffc55f2
+ 
ffc55f2
+ 	if (_ConvertFromPyObject(item, &li->li_tv, lookupDict) == -1)
ffc55f2
+ 	    return -1;
ffc55f2
+ 
ffc55f2
+ 	list_append(l, li);
ffc55f2
+ 
ffc55f2
+ 	Py_DECREF(item);
ffc55f2
+     }
ffc55f2
+ 
ffc55f2
+     Py_DECREF(iterator);
ffc55f2
+     return 0;
ffc55f2
+ }
ffc55f2
+ 
ffc55f2
  typedef int (*pytotvfunc)(PyObject *, typval_T *, PyObject *);
ffc55f2
  
ffc55f2
      static int
ffc55f2
*** ../vim-7.3.940/src/if_python.c	2013-05-12 18:44:44.000000000 +0200
ffc55f2
--- src/if_python.c	2013-05-12 19:34:35.000000000 +0200
ffc55f2
***************
ffc55f2
*** 1019,1027 ****
ffc55f2
  
ffc55f2
  #define BufferType_Check(obj) ((obj)->ob_type == &BufferType)
ffc55f2
  
ffc55f2
- static PyInt BufferLength(PyObject *);
ffc55f2
- static PyObject *BufferItem(PyObject *, PyInt);
ffc55f2
- static PyObject *BufferSlice(PyObject *, PyInt, PyInt);
ffc55f2
  static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
ffc55f2
  static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
ffc55f2
  
ffc55f2
--- 1019,1024 ----
ffc55f2
*** ../vim-7.3.940/src/version.c	2013-05-12 19:30:27.000000000 +0200
ffc55f2
--- src/version.c	2013-05-12 19:37:08.000000000 +0200
ffc55f2
***************
ffc55f2
*** 730,731 ****
ffc55f2
--- 730,733 ----
ffc55f2
  {   /* Add new patch number below this line */
ffc55f2
+ /**/
ffc55f2
+     941,
ffc55f2
  /**/
ffc55f2
ffc55f2
-- 
ffc55f2
ARTHUR:  Well, I AM king...
ffc55f2
DENNIS:  Oh king, eh, very nice.  An' how'd you get that, eh?  By exploitin'
ffc55f2
         the workers -- by 'angin' on to outdated imperialist dogma which
ffc55f2
         perpetuates the economic an' social differences in our society!  If
ffc55f2
         there's ever going to be any progress--
ffc55f2
                                  The Quest for the Holy Grail (Monty Python)
ffc55f2
ffc55f2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
ffc55f2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
ffc55f2
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
ffc55f2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///