Blame SOURCES/7.4.151

d6ba96
To: vim_dev@googlegroups.com
d6ba96
Subject: Patch 7.4.151
d6ba96
Fcc: outbox
d6ba96
From: Bram Moolenaar <Bram@moolenaar.net>
d6ba96
Mime-Version: 1.0
d6ba96
Content-Type: text/plain; charset=UTF-8
d6ba96
Content-Transfer-Encoding: 8bit
d6ba96
------------
d6ba96
d6ba96
Patch 7.4.151
d6ba96
Problem:    Python: slices with steps are not supported.
d6ba96
Solution:   Support slices in Python vim.List. (ZyX)
d6ba96
Files:	    src/eval.c, src/if_py_both.h, src/if_python3.c, src/if_python.c,
d6ba96
	    src/proto/eval.pro, src/testdir/test86.in, src/testdir/test86.ok,
d6ba96
	    src/testdir/test87.in, src/testdir/test87.ok
d6ba96
d6ba96
d6ba96
*** ../vim-7.4.150/src/eval.c	2014-01-14 15:24:24.000000000 +0100
d6ba96
--- src/eval.c	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 6425,6430 ****
d6ba96
--- 6425,6440 ----
d6ba96
      if (ni == NULL)
d6ba96
  	return FAIL;
d6ba96
      copy_tv(tv, &ni->li_tv);
d6ba96
+     list_insert(l, ni, item);
d6ba96
+     return OK;
d6ba96
+ }
d6ba96
+ 
d6ba96
+     void
d6ba96
+ list_insert(l, ni, item)
d6ba96
+     list_T	*l;
d6ba96
+     listitem_T	*ni;
d6ba96
+     listitem_T	*item;
d6ba96
+ {
d6ba96
      if (item == NULL)
d6ba96
  	/* Append new item at end of list. */
d6ba96
  	list_append(l, ni);
d6ba96
***************
d6ba96
*** 6446,6452 ****
d6ba96
  	item->li_prev = ni;
d6ba96
  	++l->lv_len;
d6ba96
      }
d6ba96
-     return OK;
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
--- 6456,6461 ----
d6ba96
*** ../vim-7.4.150/src/if_py_both.h	2014-01-10 18:16:00.000000000 +0100
d6ba96
--- src/if_py_both.h	2014-01-14 16:31:49.000000000 +0100
d6ba96
***************
d6ba96
*** 36,43 ****
d6ba96
  #define PyErr_SET_STRING(exc, str) PyErr_SetString(exc, _(str))
d6ba96
  #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
d6ba96
  #define PyErr_SET_VIM(str) PyErr_SET_STRING(VimError, str)
d6ba96
! #define PyErr_FORMAT(exc, str, tail) PyErr_Format(exc, _(str), tail)
d6ba96
! #define PyErr_VIM_FORMAT(str, tail) PyErr_FORMAT(VimError, str, tail)
d6ba96
  
d6ba96
  #define Py_TYPE_NAME(obj) (obj->ob_type->tp_name == NULL \
d6ba96
  	? "(NULL)" \
d6ba96
--- 36,44 ----
d6ba96
  #define PyErr_SET_STRING(exc, str) PyErr_SetString(exc, _(str))
d6ba96
  #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
d6ba96
  #define PyErr_SET_VIM(str) PyErr_SET_STRING(VimError, str)
d6ba96
! #define PyErr_FORMAT(exc, str, arg) PyErr_Format(exc, _(str), arg)
d6ba96
! #define PyErr_FORMAT2(exc, str, arg1, arg2) PyErr_Format(exc, _(str), arg1,arg2)
d6ba96
! #define PyErr_VIM_FORMAT(str, arg) PyErr_FORMAT(VimError, str, arg)
d6ba96
  
d6ba96
  #define Py_TYPE_NAME(obj) (obj->ob_type->tp_name == NULL \
d6ba96
  	? "(NULL)" \
d6ba96
***************
d6ba96
*** 2108,2115 ****
d6ba96
  };
d6ba96
  
d6ba96
  static PyTypeObject ListType;
d6ba96
- static PySequenceMethods ListAsSeq;
d6ba96
- static PyMappingMethods ListAsMapping;
d6ba96
  
d6ba96
  typedef struct
d6ba96
  {
d6ba96
--- 2109,2114 ----
d6ba96
***************
d6ba96
*** 2253,2259 ****
d6ba96
  }
d6ba96
  
d6ba96
      static PyObject *
d6ba96
! ListItem(ListObject *self, Py_ssize_t index)
d6ba96
  {
d6ba96
      listitem_T	*li;
d6ba96
  
d6ba96
--- 2252,2258 ----
d6ba96
  }
d6ba96
  
d6ba96
      static PyObject *
d6ba96
! ListIndex(ListObject *self, Py_ssize_t index)
d6ba96
  {
d6ba96
      listitem_T	*li;
d6ba96
  
d6ba96
***************
d6ba96
*** 2273,2436 ****
d6ba96
      return ConvertToPyObject(&li->li_tv);
d6ba96
  }
d6ba96
  
d6ba96
- #define PROC_RANGE \
d6ba96
-     if (last < 0) {\
d6ba96
- 	if (last < -size) \
d6ba96
- 	    last = 0; \
d6ba96
- 	else \
d6ba96
- 	    last += size; \
d6ba96
-     } \
d6ba96
-     if (first < 0) \
d6ba96
- 	first = 0; \
d6ba96
-     if (first > size) \
d6ba96
- 	first = size; \
d6ba96
-     if (last > size) \
d6ba96
- 	last = size;
d6ba96
- 
d6ba96
      static PyObject *
d6ba96
! ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last)
d6ba96
  {
d6ba96
      PyInt	i;
d6ba96
-     PyInt	size = ListLength(self);
d6ba96
-     PyInt	n;
d6ba96
      PyObject	*list;
d6ba96
-     int		reversed = 0;
d6ba96
  
d6ba96
!     PROC_RANGE
d6ba96
!     if (first >= last)
d6ba96
! 	first = last;
d6ba96
  
d6ba96
!     n = last-first;
d6ba96
!     list = PyList_New(n);
d6ba96
      if (list == NULL)
d6ba96
  	return NULL;
d6ba96
  
d6ba96
!     for (i = 0; i < n; ++i)
d6ba96
      {
d6ba96
! 	PyObject	*item = ListItem(self, first + i);
d6ba96
  	if (item == NULL)
d6ba96
  	{
d6ba96
  	    Py_DECREF(list);
d6ba96
  	    return NULL;
d6ba96
  	}
d6ba96
  
d6ba96
! 	PyList_SET_ITEM(list, ((reversed)?(n-i-1):(i)), item);
d6ba96
      }
d6ba96
  
d6ba96
      return list;
d6ba96
  }
d6ba96
  
d6ba96
- typedef struct
d6ba96
- {
d6ba96
-     listwatch_T	lw;
d6ba96
-     list_T	*list;
d6ba96
- } listiterinfo_T;
d6ba96
- 
d6ba96
-     static void
d6ba96
- ListIterDestruct(listiterinfo_T *lii)
d6ba96
- {
d6ba96
-     list_rem_watch(lii->list, &lii->lw);
d6ba96
-     PyMem_Free(lii);
d6ba96
- }
d6ba96
- 
d6ba96
      static PyObject *
d6ba96
! ListIterNext(listiterinfo_T **lii)
d6ba96
  {
d6ba96
!     PyObject	*ret;
d6ba96
! 
d6ba96
!     if (!((*lii)->lw.lw_item))
d6ba96
! 	return NULL;
d6ba96
! 
d6ba96
!     if (!(ret = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
d6ba96
! 	return NULL;
d6ba96
! 
d6ba96
!     (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
d6ba96
! 
d6ba96
!     return ret;
d6ba96
! }
d6ba96
! 
d6ba96
!     static PyObject *
d6ba96
! ListIter(ListObject *self)
d6ba96
! {
d6ba96
!     listiterinfo_T	*lii;
d6ba96
!     list_T	*l = self->list;
d6ba96
! 
d6ba96
!     if (!(lii = PyMem_New(listiterinfo_T, 1)))
d6ba96
      {
d6ba96
! 	PyErr_NoMemory();
d6ba96
! 	return NULL;
d6ba96
      }
d6ba96
! 
d6ba96
!     list_add_watch(l, &lii->lw);
d6ba96
!     lii->lw.lw_item = l->lv_first;
d6ba96
!     lii->list = l;
d6ba96
! 
d6ba96
!     return IterNew(lii,
d6ba96
! 	    (destructorfun) ListIterDestruct, (nextfun) ListIterNext,
d6ba96
! 	    NULL, NULL);
d6ba96
! }
d6ba96
! 
d6ba96
!     static int
d6ba96
! ListAssItem(ListObject *self, Py_ssize_t index, PyObject *obj)
d6ba96
! {
d6ba96
!     typval_T	tv;
d6ba96
!     list_T	*l = self->list;
d6ba96
!     listitem_T	*li;
d6ba96
!     Py_ssize_t	length = ListLength(self);
d6ba96
! 
d6ba96
!     if (l->lv_lock)
d6ba96
      {
d6ba96
! 	RAISE_LOCKED_LIST;
d6ba96
! 	return -1;
d6ba96
      }
d6ba96
!     if (index > length || (index == length && obj == NULL))
d6ba96
      {
d6ba96
! 	PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range"));
d6ba96
! 	return -1;
d6ba96
!     }
d6ba96
  
d6ba96
!     if (obj == NULL)
d6ba96
      {
d6ba96
! 	li = list_find(l, (long) index);
d6ba96
! 	list_remove(l, li, li);
d6ba96
! 	clear_tv(&li->li_tv);
d6ba96
! 	vim_free(li);
d6ba96
! 	return 0;
d6ba96
      }
d6ba96
  
d6ba96
!     if (ConvertFromPyObject(obj, &tv) == -1)
d6ba96
! 	return -1;
d6ba96
! 
d6ba96
!     if (index == length)
d6ba96
      {
d6ba96
! 	if (list_append_tv(l, &tv) == FAIL)
d6ba96
! 	{
d6ba96
! 	    clear_tv(&tv;;
d6ba96
! 	    PyErr_SET_VIM(N_("failed to add item to list"));
d6ba96
! 	    return -1;
d6ba96
! 	}
d6ba96
      }
d6ba96
!     else
d6ba96
      {
d6ba96
! 	li = list_find(l, (long) index);
d6ba96
! 	clear_tv(&li->li_tv);
d6ba96
! 	copy_tv(&tv, &li->li_tv);
d6ba96
! 	clear_tv(&tv;;
d6ba96
      }
d6ba96
-     return 0;
d6ba96
  }
d6ba96
  
d6ba96
      static int
d6ba96
! ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
d6ba96
  {
d6ba96
-     PyInt	size = ListLength(self);
d6ba96
      PyObject	*iterator;
d6ba96
      PyObject	*item;
d6ba96
      listitem_T	*li;
d6ba96
      listitem_T	*next;
d6ba96
      typval_T	v;
d6ba96
      list_T	*l = self->list;
d6ba96
      PyInt	i;
d6ba96
  
d6ba96
      if (l->lv_lock)
d6ba96
      {
d6ba96
--- 2272,2381 ----
d6ba96
      return ConvertToPyObject(&li->li_tv);
d6ba96
  }
d6ba96
  
d6ba96
      static PyObject *
d6ba96
! ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t step,
d6ba96
! 	  Py_ssize_t slicelen)
d6ba96
  {
d6ba96
      PyInt	i;
d6ba96
      PyObject	*list;
d6ba96
  
d6ba96
!     if (step == 0)
d6ba96
!     {
d6ba96
! 	PyErr_SET_STRING(PyExc_ValueError, N_("slice step cannot be zero"));
d6ba96
! 	return NULL;
d6ba96
!     }
d6ba96
  
d6ba96
!     list = PyList_New(slicelen);
d6ba96
      if (list == NULL)
d6ba96
  	return NULL;
d6ba96
  
d6ba96
!     for (i = 0; i < slicelen; ++i)
d6ba96
      {
d6ba96
! 	PyObject	*item;
d6ba96
! 
d6ba96
! 	item = ListIndex(self, first + i*step);
d6ba96
  	if (item == NULL)
d6ba96
  	{
d6ba96
  	    Py_DECREF(list);
d6ba96
  	    return NULL;
d6ba96
  	}
d6ba96
  
d6ba96
! 	PyList_SET_ITEM(list, i, item);
d6ba96
      }
d6ba96
  
d6ba96
      return list;
d6ba96
  }
d6ba96
  
d6ba96
      static PyObject *
d6ba96
! ListItem(ListObject *self, PyObject* idx)
d6ba96
  {
d6ba96
! #if PY_MAJOR_VERSION < 3
d6ba96
!     if (PyInt_Check(idx))
d6ba96
      {
d6ba96
! 	long _idx = PyInt_AsLong(idx);
d6ba96
! 	return ListIndex(self, _idx);
d6ba96
      }
d6ba96
!     else
d6ba96
! #endif
d6ba96
!     if (PyLong_Check(idx))
d6ba96
      {
d6ba96
! 	long _idx = PyLong_AsLong(idx);
d6ba96
! 	return ListIndex(self, _idx);
d6ba96
      }
d6ba96
!     else if (PySlice_Check(idx))
d6ba96
      {
d6ba96
! 	Py_ssize_t start, stop, step, slicelen;
d6ba96
  
d6ba96
! 	if (PySlice_GetIndicesEx(idx, ListLength(self),
d6ba96
! 				 &start, &stop, &step, &slicelen) < 0)
d6ba96
! 	    return NULL;
d6ba96
! 	return ListSlice(self, start, step, slicelen);
d6ba96
!     }
d6ba96
!     else
d6ba96
      {
d6ba96
! 	RAISE_INVALID_INDEX_TYPE(idx);
d6ba96
! 	return NULL;
d6ba96
      }
d6ba96
+ }
d6ba96
  
d6ba96
!     static void
d6ba96
! list_restore(Py_ssize_t numadded, Py_ssize_t numreplaced, Py_ssize_t slicelen,
d6ba96
! 	list_T *l, listitem_T **lis, listitem_T *lastaddedli)
d6ba96
! {
d6ba96
!     while (numreplaced--)
d6ba96
      {
d6ba96
! 	list_insert(l, lis[numreplaced], lis[slicelen + numreplaced]);
d6ba96
! 	listitem_remove(l, lis[slicelen + numreplaced]);
d6ba96
      }
d6ba96
!     while (numadded--)
d6ba96
      {
d6ba96
! 	listitem_T	*next;
d6ba96
! 
d6ba96
! 	next = lastaddedli->li_prev;
d6ba96
! 	listitem_remove(l, lastaddedli);
d6ba96
! 	lastaddedli = next;
d6ba96
      }
d6ba96
  }
d6ba96
  
d6ba96
      static int
d6ba96
! ListAssSlice(ListObject *self, Py_ssize_t first,
d6ba96
! 	     Py_ssize_t step, Py_ssize_t slicelen, PyObject *obj)
d6ba96
  {
d6ba96
      PyObject	*iterator;
d6ba96
      PyObject	*item;
d6ba96
      listitem_T	*li;
d6ba96
+     listitem_T	*lastaddedli = NULL;
d6ba96
      listitem_T	*next;
d6ba96
      typval_T	v;
d6ba96
      list_T	*l = self->list;
d6ba96
      PyInt	i;
d6ba96
+     PyInt	j;
d6ba96
+     PyInt	numreplaced = 0;
d6ba96
+     PyInt	numadded = 0;
d6ba96
+     PyInt	size;
d6ba96
+     listitem_T	**lis;
d6ba96
+ 
d6ba96
+     size = ListLength(self);
d6ba96
  
d6ba96
      if (l->lv_lock)
d6ba96
      {
d6ba96
***************
d6ba96
*** 2438,2444 ****
d6ba96
  	return -1;
d6ba96
      }
d6ba96
  
d6ba96
!     PROC_RANGE
d6ba96
  
d6ba96
      if (first == size)
d6ba96
  	li = NULL;
d6ba96
--- 2383,2424 ----
d6ba96
  	return -1;
d6ba96
      }
d6ba96
  
d6ba96
!     if (step == 0)
d6ba96
!     {
d6ba96
! 	PyErr_SET_STRING(PyExc_ValueError, N_("slice step cannot be zero"));
d6ba96
! 	return -1;
d6ba96
!     }
d6ba96
! 
d6ba96
!     if (step != 1 && slicelen == 0)
d6ba96
!     {
d6ba96
! 	/* Nothing to do. Only error out if obj has some items. */
d6ba96
! 	int		ret = 0;
d6ba96
! 
d6ba96
! 	if (obj == NULL)
d6ba96
! 	    return 0;
d6ba96
! 
d6ba96
! 	if (!(iterator = PyObject_GetIter(obj)))
d6ba96
! 	    return -1;
d6ba96
! 
d6ba96
! 	if ((item = PyIter_Next(iterator)))
d6ba96
! 	{
d6ba96
! 	    PyErr_FORMAT(PyExc_ValueError,
d6ba96
! 		    N_("attempt to assign sequence of size greater then %d "
d6ba96
! 			"to extended slice"), 0);
d6ba96
! 	    Py_DECREF(item);
d6ba96
! 	    ret = -1;
d6ba96
! 	}
d6ba96
! 	Py_DECREF(iterator);
d6ba96
! 	return ret;
d6ba96
!     }
d6ba96
! 
d6ba96
!     if (obj != NULL)
d6ba96
! 	/* XXX May allocate zero bytes. */
d6ba96
! 	if (!(lis = PyMem_New(listitem_T *, slicelen * 2)))
d6ba96
! 	{
d6ba96
! 	    PyErr_NoMemory();
d6ba96
! 	    return -1;
d6ba96
! 	}
d6ba96
  
d6ba96
      if (first == size)
d6ba96
  	li = NULL;
d6ba96
***************
d6ba96
*** 2449,2465 ****
d6ba96
  	{
d6ba96
  	    PyErr_VIM_FORMAT(N_("internal error: no vim list item %d"),
d6ba96
  		    (int)first);
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
! 	if (last > first)
d6ba96
  	{
d6ba96
! 	    i = last - first;
d6ba96
! 	    while (i-- && li != NULL)
d6ba96
! 	    {
d6ba96
! 		next = li->li_next;
d6ba96
  		listitem_remove(l, li);
d6ba96
! 		li = next;
d6ba96
! 	    }
d6ba96
  	}
d6ba96
      }
d6ba96
  
d6ba96
--- 2429,2461 ----
d6ba96
  	{
d6ba96
  	    PyErr_VIM_FORMAT(N_("internal error: no vim list item %d"),
d6ba96
  		    (int)first);
d6ba96
+ 	    if (obj != NULL)
d6ba96
+ 		PyMem_Free(lis);
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
! 	i = slicelen;
d6ba96
! 	while (i-- && li != NULL)
d6ba96
  	{
d6ba96
! 	    j = step;
d6ba96
! 	    next = li;
d6ba96
! 	    if (step > 0)
d6ba96
! 		while (next != NULL && ((next = next->li_next) != NULL) && --j);
d6ba96
! 	    else
d6ba96
! 		while (next != NULL && ((next = next->li_prev) != NULL) && ++j);
d6ba96
! 
d6ba96
! 	    if (obj == NULL)
d6ba96
  		listitem_remove(l, li);
d6ba96
! 	    else
d6ba96
! 		lis[slicelen - i - 1] = li;
d6ba96
! 
d6ba96
! 	    li = next;
d6ba96
! 	}
d6ba96
! 	if (li == NULL && i != -1)
d6ba96
! 	{
d6ba96
! 	    PyErr_SET_VIM(N_("internal error: not enough list items"));
d6ba96
! 	    if (obj != NULL)
d6ba96
! 		PyMem_Free(lis);
d6ba96
! 	    return -1;
d6ba96
  	}
d6ba96
      }
d6ba96
  
d6ba96
***************
d6ba96
*** 2467,2499 ****
d6ba96
  	return 0;
d6ba96
  
d6ba96
      if (!(iterator = PyObject_GetIter(obj)))
d6ba96
  	return -1;
d6ba96
  
d6ba96
      while ((item = PyIter_Next(iterator)))
d6ba96
      {
d6ba96
  	if (ConvertFromPyObject(item, &v) == -1)
d6ba96
  	{
d6ba96
  	    Py_DECREF(iterator);
d6ba96
  	    Py_DECREF(item);
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
  	Py_DECREF(item);
d6ba96
! 	if (list_insert_tv(l, &v, li) == FAIL)
d6ba96
  	{
d6ba96
  	    clear_tv(&v);
d6ba96
  	    PyErr_SET_VIM(N_("internal error: failed to add item to list"));
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
  	clear_tv(&v);
d6ba96
      }
d6ba96
      Py_DECREF(iterator);
d6ba96
  
d6ba96
      if (PyErr_Occurred())
d6ba96
  	return -1;
d6ba96
  
d6ba96
      return 0;
d6ba96
  }
d6ba96
  
d6ba96
      static PyObject *
d6ba96
  ListConcatInPlace(ListObject *self, PyObject *obj)
d6ba96
  {
d6ba96
--- 2463,2634 ----
d6ba96
  	return 0;
d6ba96
  
d6ba96
      if (!(iterator = PyObject_GetIter(obj)))
d6ba96
+     {
d6ba96
+ 	PyMem_Free(lis);
d6ba96
  	return -1;
d6ba96
+     }
d6ba96
  
d6ba96
+     i = 0;
d6ba96
      while ((item = PyIter_Next(iterator)))
d6ba96
      {
d6ba96
  	if (ConvertFromPyObject(item, &v) == -1)
d6ba96
  	{
d6ba96
  	    Py_DECREF(iterator);
d6ba96
  	    Py_DECREF(item);
d6ba96
+ 	    PyMem_Free(lis);
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
  	Py_DECREF(item);
d6ba96
! 	if (list_insert_tv(l, &v, numreplaced < slicelen
d6ba96
! 				    ? lis[numreplaced]
d6ba96
! 				    : li) == FAIL)
d6ba96
  	{
d6ba96
  	    clear_tv(&v);
d6ba96
  	    PyErr_SET_VIM(N_("internal error: failed to add item to list"));
d6ba96
+ 	    list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
d6ba96
+ 	    PyMem_Free(lis);
d6ba96
  	    return -1;
d6ba96
  	}
d6ba96
+ 	if (numreplaced < slicelen)
d6ba96
+ 	{
d6ba96
+ 	    lis[slicelen + numreplaced] = lis[numreplaced]->li_prev;
d6ba96
+ 	    list_remove(l, lis[numreplaced], lis[numreplaced]);
d6ba96
+ 	    numreplaced++;
d6ba96
+ 	}
d6ba96
+ 	else
d6ba96
+ 	{
d6ba96
+ 	    if (li)
d6ba96
+ 		lastaddedli = li->li_prev;
d6ba96
+ 	    else
d6ba96
+ 		lastaddedli = l->lv_last;
d6ba96
+ 	    numadded++;
d6ba96
+ 	}
d6ba96
  	clear_tv(&v);
d6ba96
+ 	if (step != 1 && i >= slicelen)
d6ba96
+ 	{
d6ba96
+ 	    Py_DECREF(iterator);
d6ba96
+ 	    PyErr_FORMAT(PyExc_ValueError,
d6ba96
+ 		    N_("attempt to assign sequence of size greater then %d "
d6ba96
+ 			"to extended slice"), slicelen);
d6ba96
+ 	    list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
d6ba96
+ 	    PyMem_Free(lis);
d6ba96
+ 	    return -1;
d6ba96
+ 	}
d6ba96
+ 	++i;
d6ba96
      }
d6ba96
      Py_DECREF(iterator);
d6ba96
  
d6ba96
+     if (step != 1 && i != slicelen)
d6ba96
+     {
d6ba96
+ 	PyErr_FORMAT2(PyExc_ValueError,
d6ba96
+ 		N_("attempt to assign sequence of size %d to extended slice "
d6ba96
+ 		    "of size %d"), i, slicelen);
d6ba96
+ 	list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
d6ba96
+ 	PyMem_Free(lis);
d6ba96
+ 	return -1;
d6ba96
+     }
d6ba96
+ 
d6ba96
      if (PyErr_Occurred())
d6ba96
+     {
d6ba96
+ 	list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
d6ba96
+ 	PyMem_Free(lis);
d6ba96
  	return -1;
d6ba96
+     }
d6ba96
+ 
d6ba96
+     for (i = 0; i < numreplaced; i++)
d6ba96
+ 	listitem_free(lis[i]);
d6ba96
+     if (step == 1)
d6ba96
+ 	for (i = numreplaced; i < slicelen; i++)
d6ba96
+ 	    listitem_remove(l, lis[i]);
d6ba96
+ 
d6ba96
+     PyMem_Free(lis);
d6ba96
  
d6ba96
      return 0;
d6ba96
  }
d6ba96
  
d6ba96
+     static int
d6ba96
+ ListAssIndex(ListObject *self, Py_ssize_t index, PyObject *obj)
d6ba96
+ {
d6ba96
+     typval_T	tv;
d6ba96
+     list_T	*l = self->list;
d6ba96
+     listitem_T	*li;
d6ba96
+     Py_ssize_t	length = ListLength(self);
d6ba96
+ 
d6ba96
+     if (l->lv_lock)
d6ba96
+     {
d6ba96
+ 	RAISE_LOCKED_LIST;
d6ba96
+ 	return -1;
d6ba96
+     }
d6ba96
+     if (index > length || (index == length && obj == NULL))
d6ba96
+     {
d6ba96
+ 	PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range"));
d6ba96
+ 	return -1;
d6ba96
+     }
d6ba96
+ 
d6ba96
+     if (obj == NULL)
d6ba96
+     {
d6ba96
+ 	li = list_find(l, (long) index);
d6ba96
+ 	list_remove(l, li, li);
d6ba96
+ 	clear_tv(&li->li_tv);
d6ba96
+ 	vim_free(li);
d6ba96
+ 	return 0;
d6ba96
+     }
d6ba96
+ 
d6ba96
+     if (ConvertFromPyObject(obj, &tv) == -1)
d6ba96
+ 	return -1;
d6ba96
+ 
d6ba96
+     if (index == length)
d6ba96
+     {
d6ba96
+ 	if (list_append_tv(l, &tv) == FAIL)
d6ba96
+ 	{
d6ba96
+ 	    clear_tv(&tv;;
d6ba96
+ 	    PyErr_SET_VIM(N_("failed to add item to list"));
d6ba96
+ 	    return -1;
d6ba96
+ 	}
d6ba96
+     }
d6ba96
+     else
d6ba96
+     {
d6ba96
+ 	li = list_find(l, (long) index);
d6ba96
+ 	clear_tv(&li->li_tv);
d6ba96
+ 	copy_tv(&tv, &li->li_tv);
d6ba96
+ 	clear_tv(&tv;;
d6ba96
+     }
d6ba96
+     return 0;
d6ba96
+ }
d6ba96
+ 
d6ba96
+     static Py_ssize_t
d6ba96
+ ListAssItem(ListObject *self, PyObject *idx, PyObject *obj)
d6ba96
+ {
d6ba96
+ #if PY_MAJOR_VERSION < 3
d6ba96
+     if (PyInt_Check(idx))
d6ba96
+     {
d6ba96
+ 	long _idx = PyInt_AsLong(idx);
d6ba96
+ 	return ListAssIndex(self, _idx, obj);
d6ba96
+     }
d6ba96
+     else
d6ba96
+ #endif
d6ba96
+     if (PyLong_Check(idx))
d6ba96
+     {
d6ba96
+ 	long _idx = PyLong_AsLong(idx);
d6ba96
+ 	return ListAssIndex(self, _idx, obj);
d6ba96
+     }
d6ba96
+     else if (PySlice_Check(idx))
d6ba96
+     {
d6ba96
+ 	Py_ssize_t start, stop, step, slicelen;
d6ba96
+ 
d6ba96
+ 	if (PySlice_GetIndicesEx(idx, ListLength(self),
d6ba96
+ 				 &start, &stop, &step, &slicelen) < 0)
d6ba96
+ 	    return -1;
d6ba96
+ 	return ListAssSlice(self, start, step, slicelen,
d6ba96
+ 		obj);
d6ba96
+     }
d6ba96
+     else
d6ba96
+     {
d6ba96
+ 	RAISE_INVALID_INDEX_TYPE(idx);
d6ba96
+ 	return -1;
d6ba96
+     }
d6ba96
+ }
d6ba96
+ 
d6ba96
      static PyObject *
d6ba96
  ListConcatInPlace(ListObject *self, PyObject *obj)
d6ba96
  {
d6ba96
***************
d6ba96
*** 2520,2525 ****
d6ba96
--- 2655,2710 ----
d6ba96
      return (PyObject *)(self);
d6ba96
  }
d6ba96
  
d6ba96
+ typedef struct
d6ba96
+ {
d6ba96
+     listwatch_T	lw;
d6ba96
+     list_T	*list;
d6ba96
+ } listiterinfo_T;
d6ba96
+ 
d6ba96
+     static void
d6ba96
+ ListIterDestruct(listiterinfo_T *lii)
d6ba96
+ {
d6ba96
+     list_rem_watch(lii->list, &lii->lw);
d6ba96
+     PyMem_Free(lii);
d6ba96
+ }
d6ba96
+ 
d6ba96
+     static PyObject *
d6ba96
+ ListIterNext(listiterinfo_T **lii)
d6ba96
+ {
d6ba96
+     PyObject	*ret;
d6ba96
+ 
d6ba96
+     if (!((*lii)->lw.lw_item))
d6ba96
+ 	return NULL;
d6ba96
+ 
d6ba96
+     if (!(ret = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
d6ba96
+ 	return NULL;
d6ba96
+ 
d6ba96
+     (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
d6ba96
+ 
d6ba96
+     return ret;
d6ba96
+ }
d6ba96
+ 
d6ba96
+     static PyObject *
d6ba96
+ ListIter(ListObject *self)
d6ba96
+ {
d6ba96
+     listiterinfo_T	*lii;
d6ba96
+     list_T	*l = self->list;
d6ba96
+ 
d6ba96
+     if (!(lii = PyMem_New(listiterinfo_T, 1)))
d6ba96
+     {
d6ba96
+ 	PyErr_NoMemory();
d6ba96
+ 	return NULL;
d6ba96
+     }
d6ba96
+ 
d6ba96
+     list_add_watch(l, &lii->lw);
d6ba96
+     lii->lw.lw_item = l->lv_first;
d6ba96
+     lii->list = l;
d6ba96
+ 
d6ba96
+     return IterNew(lii,
d6ba96
+ 	    (destructorfun) ListIterDestruct, (nextfun) ListIterNext,
d6ba96
+ 	    NULL, NULL);
d6ba96
+ }
d6ba96
+ 
d6ba96
  static char *ListAttrs[] = {
d6ba96
      "locked",
d6ba96
      NULL
d6ba96
***************
d6ba96
*** 2567,2572 ****
d6ba96
--- 2752,2776 ----
d6ba96
      }
d6ba96
  }
d6ba96
  
d6ba96
+ static PySequenceMethods ListAsSeq = {
d6ba96
+     (lenfunc)		ListLength,	 /* sq_length,	  len(x)   */
d6ba96
+     (binaryfunc)	0,		 /* RangeConcat, sq_concat,  x+y   */
d6ba96
+     0,					 /* RangeRepeat, sq_repeat,  x*n   */
d6ba96
+     (PyIntArgFunc)	ListIndex,	 /* sq_item,	  x[i]	   */
d6ba96
+     0,					 /* was_sq_slice,     x[i:j]   */
d6ba96
+     (PyIntObjArgProc)	ListAssIndex,	 /* sq_as_item,  x[i]=v   */
d6ba96
+     0,					 /* was_sq_ass_slice, x[i:j]=v */
d6ba96
+     0,					 /* sq_contains */
d6ba96
+     (binaryfunc)	ListConcatInPlace,/* sq_inplace_concat */
d6ba96
+     0,					 /* sq_inplace_repeat */
d6ba96
+ };
d6ba96
+ 
d6ba96
+ static PyMappingMethods ListAsMapping = {
d6ba96
+     /* mp_length	*/ (lenfunc) ListLength,
d6ba96
+     /* mp_subscript     */ (binaryfunc) ListItem,
d6ba96
+     /* mp_ass_subscript */ (objobjargproc) ListAssItem,
d6ba96
+ };
d6ba96
+ 
d6ba96
  static struct PyMethodDef ListMethods[] = {
d6ba96
      {"extend",	(PyCFunction)ListConcatInPlace,	METH_O,		""},
d6ba96
      {"__dir__",	(PyCFunction)ListDir,		METH_NOARGS,	""},
d6ba96
*** ../vim-7.4.150/src/if_python3.c	2013-11-03 00:28:20.000000000 +0100
d6ba96
--- src/if_python3.c	2014-01-14 16:32:40.000000000 +0100
d6ba96
***************
d6ba96
*** 97,102 ****
d6ba96
--- 97,105 ----
d6ba96
  #define Py_ssize_t_fmt "n"
d6ba96
  #define Py_bytes_fmt "y"
d6ba96
  
d6ba96
+ #define PyIntArgFunc	ssizeargfunc
d6ba96
+ #define PyIntObjArgProc	ssizeobjargproc
d6ba96
+ 
d6ba96
  #if defined(DYNAMIC_PYTHON3) || defined(PROTO)
d6ba96
  
d6ba96
  # ifndef WIN3264
d6ba96
***************
d6ba96
*** 292,298 ****
d6ba96
  static int (*py3_PyMapping_Check)(PyObject *);
d6ba96
  static PyObject* (*py3_PyMapping_Keys)(PyObject *);
d6ba96
  static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
d6ba96
! 		     Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength);
d6ba96
  static PyObject* (*py3_PyErr_NoMemory)(void);
d6ba96
  static void (*py3_Py_Finalize)(void);
d6ba96
  static void (*py3_PyErr_SetString)(PyObject *, const char *);
d6ba96
--- 295,302 ----
d6ba96
  static int (*py3_PyMapping_Check)(PyObject *);
d6ba96
  static PyObject* (*py3_PyMapping_Keys)(PyObject *);
d6ba96
  static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
d6ba96
! 		     Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
d6ba96
! 		     Py_ssize_t *slicelen);
d6ba96
  static PyObject* (*py3_PyErr_NoMemory)(void);
d6ba96
  static void (*py3_Py_Finalize)(void);
d6ba96
  static void (*py3_PyErr_SetString)(PyObject *, const char *);
d6ba96
***************
d6ba96
*** 1478,1553 ****
d6ba96
  /* List object - Definitions
d6ba96
   */
d6ba96
  
d6ba96
- static PySequenceMethods ListAsSeq = {
d6ba96
-     (lenfunc)		ListLength,	 /* sq_length,	  len(x)   */
d6ba96
-     (binaryfunc)	0,		 /* RangeConcat, sq_concat,  x+y   */
d6ba96
-     (ssizeargfunc)	0,		 /* RangeRepeat, sq_repeat,  x*n   */
d6ba96
-     (ssizeargfunc)	ListItem,	 /* sq_item,	  x[i]	   */
d6ba96
-     (void *)		0,		 /* was_sq_slice,     x[i:j]   */
d6ba96
-     (ssizeobjargproc)	ListAssItem,	 /* sq_as_item,  x[i]=v   */
d6ba96
-     (void *)		0,		 /* was_sq_ass_slice, x[i:j]=v */
d6ba96
-     0,					 /* sq_contains */
d6ba96
-     (binaryfunc)	ListConcatInPlace,/* sq_inplace_concat */
d6ba96
-     0,					 /* sq_inplace_repeat */
d6ba96
- };
d6ba96
- 
d6ba96
- static PyObject *ListSubscript(PyObject *, PyObject *);
d6ba96
- static Py_ssize_t ListAsSubscript(PyObject *, PyObject *, PyObject *);
d6ba96
- 
d6ba96
- static PyMappingMethods ListAsMapping = {
d6ba96
-     /* mp_length	*/ (lenfunc) ListLength,
d6ba96
-     /* mp_subscript     */ (binaryfunc) ListSubscript,
d6ba96
-     /* mp_ass_subscript */ (objobjargproc) ListAsSubscript,
d6ba96
- };
d6ba96
- 
d6ba96
-     static PyObject *
d6ba96
- ListSubscript(PyObject *self, PyObject* idx)
d6ba96
- {
d6ba96
-     if (PyLong_Check(idx))
d6ba96
-     {
d6ba96
- 	long _idx = PyLong_AsLong(idx);
d6ba96
- 	return ListItem((ListObject *)(self), _idx);
d6ba96
-     }
d6ba96
-     else if (PySlice_Check(idx))
d6ba96
-     {
d6ba96
- 	Py_ssize_t start, stop, step, slicelen;
d6ba96
- 
d6ba96
- 	if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)),
d6ba96
- 				 &start, &stop, &step, &slicelen) < 0)
d6ba96
- 	    return NULL;
d6ba96
- 	return ListSlice((ListObject *)(self), start, stop);
d6ba96
-     }
d6ba96
-     else
d6ba96
-     {
d6ba96
- 	RAISE_INVALID_INDEX_TYPE(idx);
d6ba96
- 	return NULL;
d6ba96
-     }
d6ba96
- }
d6ba96
- 
d6ba96
-     static Py_ssize_t
d6ba96
- ListAsSubscript(PyObject *self, PyObject *idx, PyObject *obj)
d6ba96
- {
d6ba96
-     if (PyLong_Check(idx))
d6ba96
-     {
d6ba96
- 	long _idx = PyLong_AsLong(idx);
d6ba96
- 	return ListAssItem((ListObject *)(self), _idx, obj);
d6ba96
-     }
d6ba96
-     else if (PySlice_Check(idx))
d6ba96
-     {
d6ba96
- 	Py_ssize_t start, stop, step, slicelen;
d6ba96
- 
d6ba96
- 	if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)),
d6ba96
- 				 &start, &stop, &step, &slicelen) < 0)
d6ba96
- 	    return -1;
d6ba96
- 	return ListAssSlice((ListObject *)(self), start, stop, obj);
d6ba96
-     }
d6ba96
-     else
d6ba96
-     {
d6ba96
- 	RAISE_INVALID_INDEX_TYPE(idx);
d6ba96
- 	return -1;
d6ba96
-     }
d6ba96
- }
d6ba96
- 
d6ba96
      static PyObject *
d6ba96
  ListGetattro(PyObject *self, PyObject *nameobj)
d6ba96
  {
d6ba96
--- 1482,1487 ----
d6ba96
*** ../vim-7.4.150/src/if_python.c	2013-11-03 00:28:20.000000000 +0100
d6ba96
--- src/if_python.c	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 196,201 ****
d6ba96
--- 196,202 ----
d6ba96
  # define PyTuple_Size dll_PyTuple_Size
d6ba96
  # define PyTuple_GetItem dll_PyTuple_GetItem
d6ba96
  # define PyTuple_Type (*dll_PyTuple_Type)
d6ba96
+ # define PySlice_GetIndicesEx dll_PySlice_GetIndicesEx
d6ba96
  # define PyImport_ImportModule dll_PyImport_ImportModule
d6ba96
  # define PyDict_New dll_PyDict_New
d6ba96
  # define PyDict_GetItemString dll_PyDict_GetItemString
d6ba96
***************
d6ba96
*** 241,246 ****
d6ba96
--- 242,248 ----
d6ba96
  # define PySys_GetObject dll_PySys_GetObject
d6ba96
  # define PySys_SetArgv dll_PySys_SetArgv
d6ba96
  # define PyType_Type (*dll_PyType_Type)
d6ba96
+ # define PySlice_Type (*dll_PySlice_Type)
d6ba96
  # define PyType_Ready (*dll_PyType_Ready)
d6ba96
  # define PyType_GenericAlloc dll_PyType_GenericAlloc
d6ba96
  # define Py_BuildValue dll_Py_BuildValue
d6ba96
***************
d6ba96
*** 341,346 ****
d6ba96
--- 343,351 ----
d6ba96
  static PyInt(*dll_PyTuple_Size)(PyObject *);
d6ba96
  static PyObject*(*dll_PyTuple_GetItem)(PyObject *, PyInt);
d6ba96
  static PyTypeObject* dll_PyTuple_Type;
d6ba96
+ static int (*dll_PySlice_GetIndicesEx)(PyObject *r, PyInt length,
d6ba96
+ 		     PyInt *start, PyInt *stop, PyInt *step,
d6ba96
+ 		     PyInt *slicelen);
d6ba96
  static PyObject*(*dll_PyImport_ImportModule)(const char *);
d6ba96
  static PyObject*(*dll_PyDict_New)(void);
d6ba96
  static PyObject*(*dll_PyDict_GetItemString)(PyObject *, const char *);
d6ba96
***************
d6ba96
*** 382,387 ****
d6ba96
--- 387,393 ----
d6ba96
  static PyObject *(*dll_PySys_GetObject)(char *);
d6ba96
  static int(*dll_PySys_SetArgv)(int, char **);
d6ba96
  static PyTypeObject* dll_PyType_Type;
d6ba96
+ static PyTypeObject* dll_PySlice_Type;
d6ba96
  static int (*dll_PyType_Ready)(PyTypeObject *type);
d6ba96
  static PyObject* (*dll_PyType_GenericAlloc)(PyTypeObject *type, PyInt nitems);
d6ba96
  static PyObject*(*dll_Py_BuildValue)(char *, ...);
d6ba96
***************
d6ba96
*** 521,526 ****
d6ba96
--- 527,533 ----
d6ba96
      {"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
d6ba96
      {"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
d6ba96
      {"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
d6ba96
+     {"PySlice_GetIndicesEx", (PYTHON_PROC*)&dll_PySlice_GetIndicesEx},
d6ba96
      {"PyImport_ImportModule", (PYTHON_PROC*)&dll_PyImport_ImportModule},
d6ba96
      {"PyDict_GetItemString", (PYTHON_PROC*)&dll_PyDict_GetItemString},
d6ba96
      {"PyDict_Next", (PYTHON_PROC*)&dll_PyDict_Next},
d6ba96
***************
d6ba96
*** 562,567 ****
d6ba96
--- 569,575 ----
d6ba96
      {"PySys_GetObject", (PYTHON_PROC*)&dll_PySys_GetObject},
d6ba96
      {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
d6ba96
      {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
d6ba96
+     {"PySlice_Type", (PYTHON_PROC*)&dll_PySlice_Type},
d6ba96
      {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
d6ba96
      {"PyType_GenericAlloc", (PYTHON_PROC*)&dll_PyType_GenericAlloc},
d6ba96
      {"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
d6ba96
***************
d6ba96
*** 1472,1492 ****
d6ba96
      return Py_FindMethod(DictionaryMethods, self, name);
d6ba96
  }
d6ba96
  
d6ba96
- static PySequenceMethods ListAsSeq = {
d6ba96
-     (PyInquiry)			ListLength,
d6ba96
-     (binaryfunc)		0,
d6ba96
-     (PyIntArgFunc)		0,
d6ba96
-     (PyIntArgFunc)		ListItem,
d6ba96
-     (PyIntIntArgFunc)		ListSlice,
d6ba96
-     (PyIntObjArgProc)		ListAssItem,
d6ba96
-     (PyIntIntObjArgProc)	ListAssSlice,
d6ba96
-     (objobjproc)		0,
d6ba96
- #if PY_MAJOR_VERSION >= 2
d6ba96
-     (binaryfunc)		ListConcatInPlace,
d6ba96
-     0,
d6ba96
- #endif
d6ba96
- };
d6ba96
- 
d6ba96
      static PyObject *
d6ba96
  ListGetattr(PyObject *self, char *name)
d6ba96
  {
d6ba96
--- 1480,1485 ----
d6ba96
*** ../vim-7.4.150/src/proto/eval.pro	2013-08-10 13:37:09.000000000 +0200
d6ba96
--- src/proto/eval.pro	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 60,65 ****
d6ba96
--- 60,66 ----
d6ba96
  int list_append_string __ARGS((list_T *l, char_u *str, int len));
d6ba96
  int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
d6ba96
  void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
d6ba96
+ void list_insert __ARGS((list_T *l, listitem_T *ni, listitem_T *item));
d6ba96
  int garbage_collect __ARGS((void));
d6ba96
  void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
d6ba96
  void set_ref_in_list __ARGS((list_T *l, int copyID));
d6ba96
*** ../vim-7.4.150/src/testdir/test86.in	2013-11-28 17:04:38.000000000 +0100
d6ba96
--- src/testdir/test86.in	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 135,140 ****
d6ba96
--- 135,152 ----
d6ba96
  :py l=vim.bindeval('l')
d6ba96
  :py del l[-6:2]
d6ba96
  :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py del l[::2]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py del l[3:0:-2]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py del l[2:4:-2]
d6ba96
+ :$put =string(l)
d6ba96
  :"
d6ba96
  :" Slice assignment to a list
d6ba96
  :let l = [0, 1, 2, 3]
d6ba96
***************
d6ba96
*** 169,174 ****
d6ba96
--- 181,206 ----
d6ba96
  :py l=vim.bindeval('l')
d6ba96
  :py l[0:0]=['h']
d6ba96
  :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py l[2:6:2] = [10, 20]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py l[6:2:-2] = [10, 20]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py l[6:2] = ()
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py l[6:2:1] = ()
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py l=vim.bindeval('l')
d6ba96
+ :py l[2:2:1] = ()
d6ba96
+ :$put =string(l)
d6ba96
  :"
d6ba96
  :" Locked variables
d6ba96
  :let l = [0, 1, 2, 3]
d6ba96
***************
d6ba96
*** 390,395 ****
d6ba96
--- 422,434 ----
d6ba96
  :$put =string(pyeval('l'))
d6ba96
  :py l = ll[-10:10]
d6ba96
  :$put =string(pyeval('l'))
d6ba96
+ :py l = ll[4:2:-1]
d6ba96
+ :$put =string(pyeval('l'))
d6ba96
+ :py l = ll[::2]
d6ba96
+ :$put =string(pyeval('l'))
d6ba96
+ :py l = ll[4:2:1]
d6ba96
+ :$put =string(pyeval('l'))
d6ba96
+ :py del l
d6ba96
  :"
d6ba96
  :" Vars
d6ba96
  :let g:foo = 'bac'
d6ba96
***************
d6ba96
*** 907,912 ****
d6ba96
--- 946,952 ----
d6ba96
  l = vim.List()
d6ba96
  ll = vim.List('abcE')
d6ba96
  ll.locked = True
d6ba96
+ nel = vim.List('abcO')
d6ba96
  f = vim.Function('string')
d6ba96
  fd = vim.Function('F')
d6ba96
  fdel = vim.Function('D')
d6ba96
***************
d6ba96
*** 994,999 ****
d6ba96
--- 1034,1053 ----
d6ba96
      def next(self):
d6ba96
          raise NotImplementedError('next')
d6ba96
  
d6ba96
+ class FailingIterNextN(object):
d6ba96
+     def __init__(self, n):
d6ba96
+         self.n = n
d6ba96
+ 
d6ba96
+     def __iter__(self):
d6ba96
+         return self
d6ba96
+ 
d6ba96
+     def next(self):
d6ba96
+         if self.n:
d6ba96
+             self.n -= 1
d6ba96
+             return 1
d6ba96
+         else:
d6ba96
+             raise NotImplementedError('next N')
d6ba96
+ 
d6ba96
  class FailingMappingKey(object):
d6ba96
      def __getitem__(self, item):
d6ba96
          raise NotImplementedError('getitem:mappingkey')
d6ba96
***************
d6ba96
*** 1098,1103 ****
d6ba96
--- 1152,1158 ----
d6ba96
  cb.append(">>> iter")
d6ba96
  ee('d.update(FailingMapping())')
d6ba96
  ee('d.update([FailingIterNext()])')
d6ba96
+ ee('d.update([FailingIterNextN(1)])')
d6ba96
  iter_test('d.update(%s)')
d6ba96
  convertfrompyobject_test('d.update(%s)')
d6ba96
  stringtochars_test('d.update(((%s, 0),))')
d6ba96
***************
d6ba96
*** 1120,1125 ****
d6ba96
--- 1175,1188 ----
d6ba96
  cb.append(">> ListAssSlice")
d6ba96
  ee('ll[1:100] = "abcJ"')
d6ba96
  iter_test('l[:] = %s')
d6ba96
+ ee('nel[1:10:2]  = "abcK"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[1:10:2]  = "a"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[1:1:-1]  = "a"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[:] = FailingIterNextN(2)')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
  convertfrompyobject_test('l[:] = [%s]')
d6ba96
  cb.append(">> ListConcatInPlace")
d6ba96
  iter_test('l.extend(%s)')
d6ba96
***************
d6ba96
*** 1201,1206 ****
d6ba96
--- 1264,1270 ----
d6ba96
  del dl
d6ba96
  del l
d6ba96
  del ll
d6ba96
+ del nel
d6ba96
  del f
d6ba96
  del fd
d6ba96
  del fdel
d6ba96
***************
d6ba96
*** 1214,1219 ****
d6ba96
--- 1278,1284 ----
d6ba96
  del FailingTrue
d6ba96
  del FailingIter
d6ba96
  del FailingIterNext
d6ba96
+ del FailingIterNextN
d6ba96
  del FailingMapping
d6ba96
  del FailingMappingKey
d6ba96
  del FailingList
d6ba96
*** ../vim-7.4.150/src/testdir/test86.ok	2013-11-28 17:04:38.000000000 +0100
d6ba96
--- src/testdir/test86.ok	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 41,46 ****
d6ba96
--- 41,49 ----
d6ba96
  [2, 3]
d6ba96
  [2, 3]
d6ba96
  [2, 3]
d6ba96
+ [1, 3]
d6ba96
+ [0, 2]
d6ba96
+ [0, 1, 2, 3]
d6ba96
  ['a', 0, 1, 2, 3]
d6ba96
  [0, 'b', 2, 3]
d6ba96
  [0, 1, 'c']
d6ba96
***************
d6ba96
*** 49,54 ****
d6ba96
--- 52,62 ----
d6ba96
  ['f', 2, 3]
d6ba96
  [0, 1, 'g', 2, 3]
d6ba96
  ['h']
d6ba96
+ [0, 1, 10, 3, 20, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 20, 5, 10, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
  [0, 1, 2, 3]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
***************
d6ba96
*** 96,101 ****
d6ba96
--- 104,112 ----
d6ba96
  [0, 1, 2, 3, 4, 5]
d6ba96
  [0, 1, 2, 3, 4, 5]
d6ba96
  [0, 1, 2, 3, 4, 5]
d6ba96
+ [4, 3]
d6ba96
+ [0, 2, 4]
d6ba96
+ []
d6ba96
  Abc
d6ba96
  bac
d6ba96
  def
d6ba96
***************
d6ba96
*** 599,604 ****
d6ba96
--- 610,616 ----
d6ba96
  >>> iter
d6ba96
  d.update(FailingMapping()):NotImplementedError:('keys',)
d6ba96
  d.update([FailingIterNext()]):NotImplementedError:('next',)
d6ba96
+ d.update([FailingIterNextN(1)]):NotImplementedError:('next N',)
d6ba96
  >>> Testing *Iter* using d.update(%s)
d6ba96
  d.update(FailingIter()):NotImplementedError:('iter',)
d6ba96
  d.update(FailingIterNext()):NotImplementedError:('next',)
d6ba96
***************
d6ba96
*** 829,834 ****
d6ba96
--- 841,854 ----
d6ba96
  l[:] = FailingIter():NotImplementedError:('iter',)
d6ba96
  l[:] = FailingIterNext():NotImplementedError:('next',)
d6ba96
  <<< Finished
d6ba96
+ nel[1:10:2]  = "abcK":ValueError:('attempt to assign sequence of size greater then 2 to extended slice',)
d6ba96
+ ('a', 'b', 'c', 'O')
d6ba96
+ nel[1:10:2]  = "a":ValueError:('attempt to assign sequence of size 1 to extended slice of size 2',)
d6ba96
+ ('a', 'b', 'c', 'O')
d6ba96
+ nel[1:1:-1]  = "a":ValueError:('attempt to assign sequence of size greater then 0 to extended slice',)
d6ba96
+ ('a', 'b', 'c', 'O')
d6ba96
+ nel[:] = FailingIterNextN(2):NotImplementedError:('next N',)
d6ba96
+ ('a', 'b', 'c', 'O')
d6ba96
  >>> Testing StringToChars using l[:] = [{%s : 1}]
d6ba96
  l[:] = [{1 : 1}]:TypeError:('expected str() or unicode() instance, but got int',)
d6ba96
  l[:] = [{u"\0" : 1}]:TypeError:('expected string without null bytes',)
d6ba96
*** ../vim-7.4.150/src/testdir/test87.in	2013-11-28 17:04:38.000000000 +0100
d6ba96
--- src/testdir/test87.in	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 128,133 ****
d6ba96
--- 128,145 ----
d6ba96
  :py3 l=vim.bindeval('l')
d6ba96
  :py3 del l[-6:2]
d6ba96
  :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 del l[::2]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 del l[3:0:-2]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = [0, 1, 2, 3]
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 del l[2:4:-2]
d6ba96
+ :$put =string(l)
d6ba96
  :"
d6ba96
  :" Slice assignment to a list
d6ba96
  :let l = [0, 1, 2, 3]
d6ba96
***************
d6ba96
*** 162,167 ****
d6ba96
--- 174,199 ----
d6ba96
  :py3 l=vim.bindeval('l')
d6ba96
  :py3 l[0:0]=['h']
d6ba96
  :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 l[2:6:2] = [10, 20]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 l[6:2:-2] = [10, 20]
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 l[6:2] = ()
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 l[6:2:1] = ()
d6ba96
+ :$put =string(l)
d6ba96
+ :let l = range(8)
d6ba96
+ :py3 l=vim.bindeval('l')
d6ba96
+ :py3 l[2:2:1] = ()
d6ba96
+ :$put =string(l)
d6ba96
  :"
d6ba96
  :" Locked variables
d6ba96
  :let l = [0, 1, 2, 3]
d6ba96
***************
d6ba96
*** 363,368 ****
d6ba96
--- 395,432 ----
d6ba96
  :py3 del trace_main
d6ba96
  :$put =string(l)
d6ba96
  :"
d6ba96
+ :" Slice
d6ba96
+ :py3 ll = vim.bindeval('[0, 1, 2, 3, 4, 5]')
d6ba96
+ :py3 l = ll[:4]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[2:]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[:-4]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[-2:]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[2:4]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[4:2]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[-4:-2]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[-2:-4]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[:]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[0:6]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[-10:10]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[4:2:-1]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[::2]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 l = ll[4:2:1]
d6ba96
+ :$put =string(py3eval('l'))
d6ba96
+ :py3 del l
d6ba96
+ :"
d6ba96
  :" Vars
d6ba96
  :let g:foo = 'bac'
d6ba96
  :let w:abc3 = 'def'
d6ba96
***************
d6ba96
*** 859,864 ****
d6ba96
--- 923,929 ----
d6ba96
  l = vim.List()
d6ba96
  ll = vim.List('abcE')
d6ba96
  ll.locked = True
d6ba96
+ nel = vim.List('abcO')
d6ba96
  f = vim.Function('string')
d6ba96
  fd = vim.Function('F')
d6ba96
  fdel = vim.Function('D')
d6ba96
***************
d6ba96
*** 946,951 ****
d6ba96
--- 1011,1030 ----
d6ba96
      def __next__(self):
d6ba96
          raise NotImplementedError('next')
d6ba96
  
d6ba96
+ class FailingIterNextN(object):
d6ba96
+     def __init__(self, n):
d6ba96
+         self.n = n
d6ba96
+ 
d6ba96
+     def __iter__(self):
d6ba96
+         return self
d6ba96
+ 
d6ba96
+     def __next__(self):
d6ba96
+         if self.n:
d6ba96
+             self.n -= 1
d6ba96
+             return 1
d6ba96
+         else:
d6ba96
+             raise NotImplementedError('next N')
d6ba96
+ 
d6ba96
  class FailingMappingKey(object):
d6ba96
      def __getitem__(self, item):
d6ba96
          raise NotImplementedError('getitem:mappingkey')
d6ba96
***************
d6ba96
*** 1050,1055 ****
d6ba96
--- 1129,1135 ----
d6ba96
  cb.append(">>> iter")
d6ba96
  ee('d.update(FailingMapping())')
d6ba96
  ee('d.update([FailingIterNext()])')
d6ba96
+ ee('d.update([FailingIterNextN(1)])')
d6ba96
  iter_test('d.update(%s)')
d6ba96
  convertfrompyobject_test('d.update(%s)')
d6ba96
  stringtochars_test('d.update(((%s, 0),))')
d6ba96
***************
d6ba96
*** 1072,1077 ****
d6ba96
--- 1152,1165 ----
d6ba96
  cb.append(">> ListAssSlice")
d6ba96
  ee('ll[1:100] = "abcJ"')
d6ba96
  iter_test('l[:] = %s')
d6ba96
+ ee('nel[1:10:2]  = "abcK"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[1:10:2]  = "a"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[1:1:-1]  = "a"')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
+ ee('nel[:] = FailingIterNextN(2)')
d6ba96
+ cb.append(repr(tuple(nel)))
d6ba96
  convertfrompyobject_test('l[:] = [%s]')
d6ba96
  cb.append(">> ListConcatInPlace")
d6ba96
  iter_test('l.extend(%s)')
d6ba96
***************
d6ba96
*** 1153,1158 ****
d6ba96
--- 1241,1247 ----
d6ba96
  del dl
d6ba96
  del l
d6ba96
  del ll
d6ba96
+ del nel
d6ba96
  del f
d6ba96
  del fd
d6ba96
  del fdel
d6ba96
***************
d6ba96
*** 1166,1171 ****
d6ba96
--- 1255,1261 ----
d6ba96
  del FailingTrue
d6ba96
  del FailingIter
d6ba96
  del FailingIterNext
d6ba96
+ del FailingIterNextN
d6ba96
  del FailingMapping
d6ba96
  del FailingMappingKey
d6ba96
  del FailingList
d6ba96
*** ../vim-7.4.150/src/testdir/test87.ok	2013-11-28 17:04:38.000000000 +0100
d6ba96
--- src/testdir/test87.ok	2014-01-14 16:24:49.000000000 +0100
d6ba96
***************
d6ba96
*** 41,46 ****
d6ba96
--- 41,49 ----
d6ba96
  [2, 3]
d6ba96
  [2, 3]
d6ba96
  [2, 3]
d6ba96
+ [1, 3]
d6ba96
+ [0, 2]
d6ba96
+ [0, 1, 2, 3]
d6ba96
  ['a', 0, 1, 2, 3]
d6ba96
  [0, 'b', 2, 3]
d6ba96
  [0, 1, 'c']
d6ba96
***************
d6ba96
*** 49,54 ****
d6ba96
--- 52,62 ----
d6ba96
  ['f', 2, 3]
d6ba96
  [0, 1, 'g', 2, 3]
d6ba96
  ['h']
d6ba96
+ [0, 1, 10, 3, 20, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 20, 5, 10, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
+ [0, 1, 2, 3, 4, 5, 6, 7]
d6ba96
  [0, 1, 2, 3]
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
d6ba96
  [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
d6ba96
***************
d6ba96
*** 85,90 ****
d6ba96
--- 93,112 ----
d6ba96
  vim:	Vim(let):E859:
d6ba96
  [1]
d6ba96
  [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]
d6ba96
+ [0, 1, 2, 3]
d6ba96
+ [2, 3, 4, 5]
d6ba96
+ [0, 1]
d6ba96
+ [4, 5]
d6ba96
+ [2, 3]
d6ba96
+ []
d6ba96
+ [2, 3]
d6ba96
+ []
d6ba96
+ [0, 1, 2, 3, 4, 5]
d6ba96
+ [0, 1, 2, 3, 4, 5]
d6ba96
+ [0, 1, 2, 3, 4, 5]
d6ba96
+ [4, 3]
d6ba96
+ [0, 2, 4]
d6ba96
+ []
d6ba96
  Abc
d6ba96
  bac
d6ba96
  def
d6ba96
***************
d6ba96
*** 588,593 ****
d6ba96
--- 610,616 ----
d6ba96
  >>> iter
d6ba96
  d.update(FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',))
d6ba96
  d.update([FailingIterNext()]):(<class 'NotImplementedError'>, NotImplementedError('next',))
d6ba96
+ d.update([FailingIterNextN(1)]):(<class 'NotImplementedError'>, NotImplementedError('next N',))
d6ba96
  >>> Testing *Iter* using d.update(%s)
d6ba96
  d.update(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',))
d6ba96
  d.update(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',))
d6ba96
***************
d6ba96
*** 818,823 ****
d6ba96
--- 841,854 ----
d6ba96
  l[:] = FailingIter():(<class 'NotImplementedError'>, NotImplementedError('iter',))
d6ba96
  l[:] = FailingIterNext():(<class 'NotImplementedError'>, NotImplementedError('next',))
d6ba96
  <<< Finished
d6ba96
+ nel[1:10:2]  = "abcK":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater then 2 to extended slice',))
d6ba96
+ (b'a', b'b', b'c', b'O')
d6ba96
+ nel[1:10:2]  = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size 1 to extended slice of size 2',))
d6ba96
+ (b'a', b'b', b'c', b'O')
d6ba96
+ nel[1:1:-1]  = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater then 0 to extended slice',))
d6ba96
+ (b'a', b'b', b'c', b'O')
d6ba96
+ nel[:] = FailingIterNextN(2):(<class 'NotImplementedError'>, NotImplementedError('next N',))
d6ba96
+ (b'a', b'b', b'c', b'O')
d6ba96
  >>> Testing StringToChars using l[:] = [{%s : 1}]
d6ba96
  l[:] = [{1 : 1}]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
d6ba96
  l[:] = [{b"\0" : 1}]:(<class 'TypeError'>, TypeError('expected bytes with no null',))
d6ba96
*** ../vim-7.4.150/src/version.c	2014-01-14 15:53:47.000000000 +0100
d6ba96
--- src/version.c	2014-01-14 16:27:01.000000000 +0100
d6ba96
***************
d6ba96
*** 740,741 ****
d6ba96
--- 740,743 ----
d6ba96
  {   /* Add new patch number below this line */
d6ba96
+ /**/
d6ba96
+     151,
d6ba96
  /**/
d6ba96
d6ba96
-- 
d6ba96
hundred-and-one symptoms of being an internet addict:
d6ba96
159. You get excited whenever discussing your hard drive.
d6ba96
d6ba96
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d6ba96
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d6ba96
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d6ba96
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///