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