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