home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.151 < prev    next >
Encoding:
Internet Message Format  |  2014-01-13  |  36.7 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.151
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.151
  11. Problem:    Python: slices with steps are not supported.
  12. Solution:   Support slices in Python vim.List. (ZyX)
  13. Files:        src/eval.c, src/if_py_both.h, src/if_python3.c, src/if_python.c,
  14.         src/proto/eval.pro, src/testdir/test86.in, src/testdir/test86.ok,
  15.         src/testdir/test87.in, src/testdir/test87.ok
  16.  
  17.  
  18. *** ../vim-7.4.150/src/eval.c    2014-01-14 15:24:24.000000000 +0100
  19. --- src/eval.c    2014-01-14 16:24:49.000000000 +0100
  20. ***************
  21. *** 6425,6430 ****
  22. --- 6425,6440 ----
  23.       if (ni == NULL)
  24.       return FAIL;
  25.       copy_tv(tv, &ni->li_tv);
  26. +     list_insert(l, ni, item);
  27. +     return OK;
  28. + }
  29. +     void
  30. + list_insert(l, ni, item)
  31. +     list_T    *l;
  32. +     listitem_T    *ni;
  33. +     listitem_T    *item;
  34. + {
  35.       if (item == NULL)
  36.       /* Append new item at end of list. */
  37.       list_append(l, ni);
  38. ***************
  39. *** 6446,6452 ****
  40.       item->li_prev = ni;
  41.       ++l->lv_len;
  42.       }
  43. -     return OK;
  44.   }
  45.   
  46.   /*
  47. --- 6456,6461 ----
  48. *** ../vim-7.4.150/src/if_py_both.h    2014-01-10 18:16:00.000000000 +0100
  49. --- src/if_py_both.h    2014-01-14 16:31:49.000000000 +0100
  50. ***************
  51. *** 36,43 ****
  52.   #define PyErr_SET_STRING(exc, str) PyErr_SetString(exc, _(str))
  53.   #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
  54.   #define PyErr_SET_VIM(str) PyErr_SET_STRING(VimError, str)
  55. ! #define PyErr_FORMAT(exc, str, tail) PyErr_Format(exc, _(str), tail)
  56. ! #define PyErr_VIM_FORMAT(str, tail) PyErr_FORMAT(VimError, str, tail)
  57.   
  58.   #define Py_TYPE_NAME(obj) (obj->ob_type->tp_name == NULL \
  59.       ? "(NULL)" \
  60. --- 36,44 ----
  61.   #define PyErr_SET_STRING(exc, str) PyErr_SetString(exc, _(str))
  62.   #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
  63.   #define PyErr_SET_VIM(str) PyErr_SET_STRING(VimError, str)
  64. ! #define PyErr_FORMAT(exc, str, arg) PyErr_Format(exc, _(str), arg)
  65. ! #define PyErr_FORMAT2(exc, str, arg1, arg2) PyErr_Format(exc, _(str), arg1,arg2)
  66. ! #define PyErr_VIM_FORMAT(str, arg) PyErr_FORMAT(VimError, str, arg)
  67.   
  68.   #define Py_TYPE_NAME(obj) (obj->ob_type->tp_name == NULL \
  69.       ? "(NULL)" \
  70. ***************
  71. *** 2108,2115 ****
  72.   };
  73.   
  74.   static PyTypeObject ListType;
  75. - static PySequenceMethods ListAsSeq;
  76. - static PyMappingMethods ListAsMapping;
  77.   
  78.   typedef struct
  79.   {
  80. --- 2109,2114 ----
  81. ***************
  82. *** 2253,2259 ****
  83.   }
  84.   
  85.       static PyObject *
  86. ! ListItem(ListObject *self, Py_ssize_t index)
  87.   {
  88.       listitem_T    *li;
  89.   
  90. --- 2252,2258 ----
  91.   }
  92.   
  93.       static PyObject *
  94. ! ListIndex(ListObject *self, Py_ssize_t index)
  95.   {
  96.       listitem_T    *li;
  97.   
  98. ***************
  99. *** 2273,2436 ****
  100.       return ConvertToPyObject(&li->li_tv);
  101.   }
  102.   
  103. - #define PROC_RANGE \
  104. -     if (last < 0) {\
  105. -     if (last < -size) \
  106. -         last = 0; \
  107. -     else \
  108. -         last += size; \
  109. -     } \
  110. -     if (first < 0) \
  111. -     first = 0; \
  112. -     if (first > size) \
  113. -     first = size; \
  114. -     if (last > size) \
  115. -     last = size;
  116.       static PyObject *
  117. ! ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last)
  118.   {
  119.       PyInt    i;
  120. -     PyInt    size = ListLength(self);
  121. -     PyInt    n;
  122.       PyObject    *list;
  123. -     int        reversed = 0;
  124.   
  125. !     PROC_RANGE
  126. !     if (first >= last)
  127. !     first = last;
  128.   
  129. !     n = last-first;
  130. !     list = PyList_New(n);
  131.       if (list == NULL)
  132.       return NULL;
  133.   
  134. !     for (i = 0; i < n; ++i)
  135.       {
  136. !     PyObject    *item = ListItem(self, first + i);
  137.       if (item == NULL)
  138.       {
  139.           Py_DECREF(list);
  140.           return NULL;
  141.       }
  142.   
  143. !     PyList_SET_ITEM(list, ((reversed)?(n-i-1):(i)), item);
  144.       }
  145.   
  146.       return list;
  147.   }
  148.   
  149. - typedef struct
  150. - {
  151. -     listwatch_T    lw;
  152. -     list_T    *list;
  153. - } listiterinfo_T;
  154. -     static void
  155. - ListIterDestruct(listiterinfo_T *lii)
  156. - {
  157. -     list_rem_watch(lii->list, &lii->lw);
  158. -     PyMem_Free(lii);
  159. - }
  160.       static PyObject *
  161. ! ListIterNext(listiterinfo_T **lii)
  162.   {
  163. !     PyObject    *ret;
  164. !     if (!((*lii)->lw.lw_item))
  165. !     return NULL;
  166. !     if (!(ret = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
  167. !     return NULL;
  168. !     (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
  169. !     return ret;
  170. ! }
  171. !     static PyObject *
  172. ! ListIter(ListObject *self)
  173. ! {
  174. !     listiterinfo_T    *lii;
  175. !     list_T    *l = self->list;
  176. !     if (!(lii = PyMem_New(listiterinfo_T, 1)))
  177.       {
  178. !     PyErr_NoMemory();
  179. !     return NULL;
  180.       }
  181. !     list_add_watch(l, &lii->lw);
  182. !     lii->lw.lw_item = l->lv_first;
  183. !     lii->list = l;
  184. !     return IterNew(lii,
  185. !         (destructorfun) ListIterDestruct, (nextfun) ListIterNext,
  186. !         NULL, NULL);
  187. ! }
  188. !     static int
  189. ! ListAssItem(ListObject *self, Py_ssize_t index, PyObject *obj)
  190. ! {
  191. !     typval_T    tv;
  192. !     list_T    *l = self->list;
  193. !     listitem_T    *li;
  194. !     Py_ssize_t    length = ListLength(self);
  195. !     if (l->lv_lock)
  196.       {
  197. !     RAISE_LOCKED_LIST;
  198. !     return -1;
  199.       }
  200. !     if (index > length || (index == length && obj == NULL))
  201.       {
  202. !     PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range"));
  203. !     return -1;
  204. !     }
  205.   
  206. !     if (obj == NULL)
  207.       {
  208. !     li = list_find(l, (long) index);
  209. !     list_remove(l, li, li);
  210. !     clear_tv(&li->li_tv);
  211. !     vim_free(li);
  212. !     return 0;
  213.       }
  214.   
  215. !     if (ConvertFromPyObject(obj, &tv) == -1)
  216. !     return -1;
  217. !     if (index == length)
  218.       {
  219. !     if (list_append_tv(l, &tv) == FAIL)
  220. !     {
  221. !         clear_tv(&tv);
  222. !         PyErr_SET_VIM(N_("failed to add item to list"));
  223. !         return -1;
  224. !     }
  225.       }
  226. !     else
  227.       {
  228. !     li = list_find(l, (long) index);
  229. !     clear_tv(&li->li_tv);
  230. !     copy_tv(&tv, &li->li_tv);
  231. !     clear_tv(&tv);
  232.       }
  233. -     return 0;
  234.   }
  235.   
  236.       static int
  237. ! ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
  238.   {
  239. -     PyInt    size = ListLength(self);
  240.       PyObject    *iterator;
  241.       PyObject    *item;
  242.       listitem_T    *li;
  243.       listitem_T    *next;
  244.       typval_T    v;
  245.       list_T    *l = self->list;
  246.       PyInt    i;
  247.   
  248.       if (l->lv_lock)
  249.       {
  250. --- 2272,2381 ----
  251.       return ConvertToPyObject(&li->li_tv);
  252.   }
  253.   
  254.       static PyObject *
  255. ! ListSlice(ListObject *self, Py_ssize_t first, Py_ssize_t step,
  256. !       Py_ssize_t slicelen)
  257.   {
  258.       PyInt    i;
  259.       PyObject    *list;
  260.   
  261. !     if (step == 0)
  262. !     {
  263. !     PyErr_SET_STRING(PyExc_ValueError, N_("slice step cannot be zero"));
  264. !     return NULL;
  265. !     }
  266.   
  267. !     list = PyList_New(slicelen);
  268.       if (list == NULL)
  269.       return NULL;
  270.   
  271. !     for (i = 0; i < slicelen; ++i)
  272.       {
  273. !     PyObject    *item;
  274. !     item = ListIndex(self, first + i*step);
  275.       if (item == NULL)
  276.       {
  277.           Py_DECREF(list);
  278.           return NULL;
  279.       }
  280.   
  281. !     PyList_SET_ITEM(list, i, item);
  282.       }
  283.   
  284.       return list;
  285.   }
  286.   
  287.       static PyObject *
  288. ! ListItem(ListObject *self, PyObject* idx)
  289.   {
  290. ! #if PY_MAJOR_VERSION < 3
  291. !     if (PyInt_Check(idx))
  292.       {
  293. !     long _idx = PyInt_AsLong(idx);
  294. !     return ListIndex(self, _idx);
  295.       }
  296. !     else
  297. ! #endif
  298. !     if (PyLong_Check(idx))
  299.       {
  300. !     long _idx = PyLong_AsLong(idx);
  301. !     return ListIndex(self, _idx);
  302.       }
  303. !     else if (PySlice_Check(idx))
  304.       {
  305. !     Py_ssize_t start, stop, step, slicelen;
  306.   
  307. !     if (PySlice_GetIndicesEx(idx, ListLength(self),
  308. !                  &start, &stop, &step, &slicelen) < 0)
  309. !         return NULL;
  310. !     return ListSlice(self, start, step, slicelen);
  311. !     }
  312. !     else
  313.       {
  314. !     RAISE_INVALID_INDEX_TYPE(idx);
  315. !     return NULL;
  316.       }
  317. + }
  318.   
  319. !     static void
  320. ! list_restore(Py_ssize_t numadded, Py_ssize_t numreplaced, Py_ssize_t slicelen,
  321. !     list_T *l, listitem_T **lis, listitem_T *lastaddedli)
  322. ! {
  323. !     while (numreplaced--)
  324.       {
  325. !     list_insert(l, lis[numreplaced], lis[slicelen + numreplaced]);
  326. !     listitem_remove(l, lis[slicelen + numreplaced]);
  327.       }
  328. !     while (numadded--)
  329.       {
  330. !     listitem_T    *next;
  331. !     next = lastaddedli->li_prev;
  332. !     listitem_remove(l, lastaddedli);
  333. !     lastaddedli = next;
  334.       }
  335.   }
  336.   
  337.       static int
  338. ! ListAssSlice(ListObject *self, Py_ssize_t first,
  339. !          Py_ssize_t step, Py_ssize_t slicelen, PyObject *obj)
  340.   {
  341.       PyObject    *iterator;
  342.       PyObject    *item;
  343.       listitem_T    *li;
  344. +     listitem_T    *lastaddedli = NULL;
  345.       listitem_T    *next;
  346.       typval_T    v;
  347.       list_T    *l = self->list;
  348.       PyInt    i;
  349. +     PyInt    j;
  350. +     PyInt    numreplaced = 0;
  351. +     PyInt    numadded = 0;
  352. +     PyInt    size;
  353. +     listitem_T    **lis;
  354. +     size = ListLength(self);
  355.   
  356.       if (l->lv_lock)
  357.       {
  358. ***************
  359. *** 2438,2444 ****
  360.       return -1;
  361.       }
  362.   
  363. !     PROC_RANGE
  364.   
  365.       if (first == size)
  366.       li = NULL;
  367. --- 2383,2424 ----
  368.       return -1;
  369.       }
  370.   
  371. !     if (step == 0)
  372. !     {
  373. !     PyErr_SET_STRING(PyExc_ValueError, N_("slice step cannot be zero"));
  374. !     return -1;
  375. !     }
  376. !     if (step != 1 && slicelen == 0)
  377. !     {
  378. !     /* Nothing to do. Only error out if obj has some items. */
  379. !     int        ret = 0;
  380. !     if (obj == NULL)
  381. !         return 0;
  382. !     if (!(iterator = PyObject_GetIter(obj)))
  383. !         return -1;
  384. !     if ((item = PyIter_Next(iterator)))
  385. !     {
  386. !         PyErr_FORMAT(PyExc_ValueError,
  387. !             N_("attempt to assign sequence of size greater then %d "
  388. !             "to extended slice"), 0);
  389. !         Py_DECREF(item);
  390. !         ret = -1;
  391. !     }
  392. !     Py_DECREF(iterator);
  393. !     return ret;
  394. !     }
  395. !     if (obj != NULL)
  396. !     /* XXX May allocate zero bytes. */
  397. !     if (!(lis = PyMem_New(listitem_T *, slicelen * 2)))
  398. !     {
  399. !         PyErr_NoMemory();
  400. !         return -1;
  401. !     }
  402.   
  403.       if (first == size)
  404.       li = NULL;
  405. ***************
  406. *** 2449,2465 ****
  407.       {
  408.           PyErr_VIM_FORMAT(N_("internal error: no vim list item %d"),
  409.               (int)first);
  410.           return -1;
  411.       }
  412. !     if (last > first)
  413.       {
  414. !         i = last - first;
  415. !         while (i-- && li != NULL)
  416. !         {
  417. !         next = li->li_next;
  418.           listitem_remove(l, li);
  419. !         li = next;
  420. !         }
  421.       }
  422.       }
  423.   
  424. --- 2429,2461 ----
  425.       {
  426.           PyErr_VIM_FORMAT(N_("internal error: no vim list item %d"),
  427.               (int)first);
  428. +         if (obj != NULL)
  429. +         PyMem_Free(lis);
  430.           return -1;
  431.       }
  432. !     i = slicelen;
  433. !     while (i-- && li != NULL)
  434.       {
  435. !         j = step;
  436. !         next = li;
  437. !         if (step > 0)
  438. !         while (next != NULL && ((next = next->li_next) != NULL) && --j);
  439. !         else
  440. !         while (next != NULL && ((next = next->li_prev) != NULL) && ++j);
  441. !         if (obj == NULL)
  442.           listitem_remove(l, li);
  443. !         else
  444. !         lis[slicelen - i - 1] = li;
  445. !         li = next;
  446. !     }
  447. !     if (li == NULL && i != -1)
  448. !     {
  449. !         PyErr_SET_VIM(N_("internal error: not enough list items"));
  450. !         if (obj != NULL)
  451. !         PyMem_Free(lis);
  452. !         return -1;
  453.       }
  454.       }
  455.   
  456. ***************
  457. *** 2467,2499 ****
  458.       return 0;
  459.   
  460.       if (!(iterator = PyObject_GetIter(obj)))
  461.       return -1;
  462.   
  463.       while ((item = PyIter_Next(iterator)))
  464.       {
  465.       if (ConvertFromPyObject(item, &v) == -1)
  466.       {
  467.           Py_DECREF(iterator);
  468.           Py_DECREF(item);
  469.           return -1;
  470.       }
  471.       Py_DECREF(item);
  472. !     if (list_insert_tv(l, &v, li) == FAIL)
  473.       {
  474.           clear_tv(&v);
  475.           PyErr_SET_VIM(N_("internal error: failed to add item to list"));
  476.           return -1;
  477.       }
  478.       clear_tv(&v);
  479.       }
  480.       Py_DECREF(iterator);
  481.   
  482.       if (PyErr_Occurred())
  483.       return -1;
  484.   
  485.       return 0;
  486.   }
  487.   
  488.       static PyObject *
  489.   ListConcatInPlace(ListObject *self, PyObject *obj)
  490.   {
  491. --- 2463,2634 ----
  492.       return 0;
  493.   
  494.       if (!(iterator = PyObject_GetIter(obj)))
  495. +     {
  496. +     PyMem_Free(lis);
  497.       return -1;
  498. +     }
  499.   
  500. +     i = 0;
  501.       while ((item = PyIter_Next(iterator)))
  502.       {
  503.       if (ConvertFromPyObject(item, &v) == -1)
  504.       {
  505.           Py_DECREF(iterator);
  506.           Py_DECREF(item);
  507. +         PyMem_Free(lis);
  508.           return -1;
  509.       }
  510.       Py_DECREF(item);
  511. !     if (list_insert_tv(l, &v, numreplaced < slicelen
  512. !                     ? lis[numreplaced]
  513. !                     : li) == FAIL)
  514.       {
  515.           clear_tv(&v);
  516.           PyErr_SET_VIM(N_("internal error: failed to add item to list"));
  517. +         list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
  518. +         PyMem_Free(lis);
  519.           return -1;
  520.       }
  521. +     if (numreplaced < slicelen)
  522. +     {
  523. +         lis[slicelen + numreplaced] = lis[numreplaced]->li_prev;
  524. +         list_remove(l, lis[numreplaced], lis[numreplaced]);
  525. +         numreplaced++;
  526. +     }
  527. +     else
  528. +     {
  529. +         if (li)
  530. +         lastaddedli = li->li_prev;
  531. +         else
  532. +         lastaddedli = l->lv_last;
  533. +         numadded++;
  534. +     }
  535.       clear_tv(&v);
  536. +     if (step != 1 && i >= slicelen)
  537. +     {
  538. +         Py_DECREF(iterator);
  539. +         PyErr_FORMAT(PyExc_ValueError,
  540. +             N_("attempt to assign sequence of size greater then %d "
  541. +             "to extended slice"), slicelen);
  542. +         list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
  543. +         PyMem_Free(lis);
  544. +         return -1;
  545. +     }
  546. +     ++i;
  547.       }
  548.       Py_DECREF(iterator);
  549.   
  550. +     if (step != 1 && i != slicelen)
  551. +     {
  552. +     PyErr_FORMAT2(PyExc_ValueError,
  553. +         N_("attempt to assign sequence of size %d to extended slice "
  554. +             "of size %d"), i, slicelen);
  555. +     list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
  556. +     PyMem_Free(lis);
  557. +     return -1;
  558. +     }
  559.       if (PyErr_Occurred())
  560. +     {
  561. +     list_restore(numadded, numreplaced, slicelen, l, lis, lastaddedli);
  562. +     PyMem_Free(lis);
  563.       return -1;
  564. +     }
  565. +     for (i = 0; i < numreplaced; i++)
  566. +     listitem_free(lis[i]);
  567. +     if (step == 1)
  568. +     for (i = numreplaced; i < slicelen; i++)
  569. +         listitem_remove(l, lis[i]);
  570. +     PyMem_Free(lis);
  571.   
  572.       return 0;
  573.   }
  574.   
  575. +     static int
  576. + ListAssIndex(ListObject *self, Py_ssize_t index, PyObject *obj)
  577. + {
  578. +     typval_T    tv;
  579. +     list_T    *l = self->list;
  580. +     listitem_T    *li;
  581. +     Py_ssize_t    length = ListLength(self);
  582. +     if (l->lv_lock)
  583. +     {
  584. +     RAISE_LOCKED_LIST;
  585. +     return -1;
  586. +     }
  587. +     if (index > length || (index == length && obj == NULL))
  588. +     {
  589. +     PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range"));
  590. +     return -1;
  591. +     }
  592. +     if (obj == NULL)
  593. +     {
  594. +     li = list_find(l, (long) index);
  595. +     list_remove(l, li, li);
  596. +     clear_tv(&li->li_tv);
  597. +     vim_free(li);
  598. +     return 0;
  599. +     }
  600. +     if (ConvertFromPyObject(obj, &tv) == -1)
  601. +     return -1;
  602. +     if (index == length)
  603. +     {
  604. +     if (list_append_tv(l, &tv) == FAIL)
  605. +     {
  606. +         clear_tv(&tv);
  607. +         PyErr_SET_VIM(N_("failed to add item to list"));
  608. +         return -1;
  609. +     }
  610. +     }
  611. +     else
  612. +     {
  613. +     li = list_find(l, (long) index);
  614. +     clear_tv(&li->li_tv);
  615. +     copy_tv(&tv, &li->li_tv);
  616. +     clear_tv(&tv);
  617. +     }
  618. +     return 0;
  619. + }
  620. +     static Py_ssize_t
  621. + ListAssItem(ListObject *self, PyObject *idx, PyObject *obj)
  622. + {
  623. + #if PY_MAJOR_VERSION < 3
  624. +     if (PyInt_Check(idx))
  625. +     {
  626. +     long _idx = PyInt_AsLong(idx);
  627. +     return ListAssIndex(self, _idx, obj);
  628. +     }
  629. +     else
  630. + #endif
  631. +     if (PyLong_Check(idx))
  632. +     {
  633. +     long _idx = PyLong_AsLong(idx);
  634. +     return ListAssIndex(self, _idx, obj);
  635. +     }
  636. +     else if (PySlice_Check(idx))
  637. +     {
  638. +     Py_ssize_t start, stop, step, slicelen;
  639. +     if (PySlice_GetIndicesEx(idx, ListLength(self),
  640. +                  &start, &stop, &step, &slicelen) < 0)
  641. +         return -1;
  642. +     return ListAssSlice(self, start, step, slicelen,
  643. +         obj);
  644. +     }
  645. +     else
  646. +     {
  647. +     RAISE_INVALID_INDEX_TYPE(idx);
  648. +     return -1;
  649. +     }
  650. + }
  651.       static PyObject *
  652.   ListConcatInPlace(ListObject *self, PyObject *obj)
  653.   {
  654. ***************
  655. *** 2520,2525 ****
  656. --- 2655,2710 ----
  657.       return (PyObject *)(self);
  658.   }
  659.   
  660. + typedef struct
  661. + {
  662. +     listwatch_T    lw;
  663. +     list_T    *list;
  664. + } listiterinfo_T;
  665. +     static void
  666. + ListIterDestruct(listiterinfo_T *lii)
  667. + {
  668. +     list_rem_watch(lii->list, &lii->lw);
  669. +     PyMem_Free(lii);
  670. + }
  671. +     static PyObject *
  672. + ListIterNext(listiterinfo_T **lii)
  673. + {
  674. +     PyObject    *ret;
  675. +     if (!((*lii)->lw.lw_item))
  676. +     return NULL;
  677. +     if (!(ret = ConvertToPyObject(&((*lii)->lw.lw_item->li_tv))))
  678. +     return NULL;
  679. +     (*lii)->lw.lw_item = (*lii)->lw.lw_item->li_next;
  680. +     return ret;
  681. + }
  682. +     static PyObject *
  683. + ListIter(ListObject *self)
  684. + {
  685. +     listiterinfo_T    *lii;
  686. +     list_T    *l = self->list;
  687. +     if (!(lii = PyMem_New(listiterinfo_T, 1)))
  688. +     {
  689. +     PyErr_NoMemory();
  690. +     return NULL;
  691. +     }
  692. +     list_add_watch(l, &lii->lw);
  693. +     lii->lw.lw_item = l->lv_first;
  694. +     lii->list = l;
  695. +     return IterNew(lii,
  696. +         (destructorfun) ListIterDestruct, (nextfun) ListIterNext,
  697. +         NULL, NULL);
  698. + }
  699.   static char *ListAttrs[] = {
  700.       "locked",
  701.       NULL
  702. ***************
  703. *** 2567,2572 ****
  704. --- 2752,2776 ----
  705.       }
  706.   }
  707.   
  708. + static PySequenceMethods ListAsSeq = {
  709. +     (lenfunc)        ListLength,     /* sq_length,      len(x)   */
  710. +     (binaryfunc)    0,         /* RangeConcat, sq_concat,  x+y   */
  711. +     0,                     /* RangeRepeat, sq_repeat,  x*n   */
  712. +     (PyIntArgFunc)    ListIndex,     /* sq_item,      x[i]       */
  713. +     0,                     /* was_sq_slice,     x[i:j]   */
  714. +     (PyIntObjArgProc)    ListAssIndex,     /* sq_as_item,  x[i]=v   */
  715. +     0,                     /* was_sq_ass_slice, x[i:j]=v */
  716. +     0,                     /* sq_contains */
  717. +     (binaryfunc)    ListConcatInPlace,/* sq_inplace_concat */
  718. +     0,                     /* sq_inplace_repeat */
  719. + };
  720. + static PyMappingMethods ListAsMapping = {
  721. +     /* mp_length    */ (lenfunc) ListLength,
  722. +     /* mp_subscript     */ (binaryfunc) ListItem,
  723. +     /* mp_ass_subscript */ (objobjargproc) ListAssItem,
  724. + };
  725.   static struct PyMethodDef ListMethods[] = {
  726.       {"extend",    (PyCFunction)ListConcatInPlace,    METH_O,        ""},
  727.       {"__dir__",    (PyCFunction)ListDir,        METH_NOARGS,    ""},
  728. *** ../vim-7.4.150/src/if_python3.c    2013-11-03 00:28:20.000000000 +0100
  729. --- src/if_python3.c    2014-01-14 16:32:40.000000000 +0100
  730. ***************
  731. *** 97,102 ****
  732. --- 97,105 ----
  733.   #define Py_ssize_t_fmt "n"
  734.   #define Py_bytes_fmt "y"
  735.   
  736. + #define PyIntArgFunc    ssizeargfunc
  737. + #define PyIntObjArgProc    ssizeobjargproc
  738.   #if defined(DYNAMIC_PYTHON3) || defined(PROTO)
  739.   
  740.   # ifndef WIN3264
  741. ***************
  742. *** 292,298 ****
  743.   static int (*py3_PyMapping_Check)(PyObject *);
  744.   static PyObject* (*py3_PyMapping_Keys)(PyObject *);
  745.   static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
  746. !              Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength);
  747.   static PyObject* (*py3_PyErr_NoMemory)(void);
  748.   static void (*py3_Py_Finalize)(void);
  749.   static void (*py3_PyErr_SetString)(PyObject *, const char *);
  750. --- 295,302 ----
  751.   static int (*py3_PyMapping_Check)(PyObject *);
  752.   static PyObject* (*py3_PyMapping_Keys)(PyObject *);
  753.   static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
  754. !              Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
  755. !              Py_ssize_t *slicelen);
  756.   static PyObject* (*py3_PyErr_NoMemory)(void);
  757.   static void (*py3_Py_Finalize)(void);
  758.   static void (*py3_PyErr_SetString)(PyObject *, const char *);
  759. ***************
  760. *** 1478,1553 ****
  761.   /* List object - Definitions
  762.    */
  763.   
  764. - static PySequenceMethods ListAsSeq = {
  765. -     (lenfunc)        ListLength,     /* sq_length,      len(x)   */
  766. -     (binaryfunc)    0,         /* RangeConcat, sq_concat,  x+y   */
  767. -     (ssizeargfunc)    0,         /* RangeRepeat, sq_repeat,  x*n   */
  768. -     (ssizeargfunc)    ListItem,     /* sq_item,      x[i]       */
  769. -     (void *)        0,         /* was_sq_slice,     x[i:j]   */
  770. -     (ssizeobjargproc)    ListAssItem,     /* sq_as_item,  x[i]=v   */
  771. -     (void *)        0,         /* was_sq_ass_slice, x[i:j]=v */
  772. -     0,                     /* sq_contains */
  773. -     (binaryfunc)    ListConcatInPlace,/* sq_inplace_concat */
  774. -     0,                     /* sq_inplace_repeat */
  775. - };
  776. - static PyObject *ListSubscript(PyObject *, PyObject *);
  777. - static Py_ssize_t ListAsSubscript(PyObject *, PyObject *, PyObject *);
  778. - static PyMappingMethods ListAsMapping = {
  779. -     /* mp_length    */ (lenfunc) ListLength,
  780. -     /* mp_subscript     */ (binaryfunc) ListSubscript,
  781. -     /* mp_ass_subscript */ (objobjargproc) ListAsSubscript,
  782. - };
  783. -     static PyObject *
  784. - ListSubscript(PyObject *self, PyObject* idx)
  785. - {
  786. -     if (PyLong_Check(idx))
  787. -     {
  788. -     long _idx = PyLong_AsLong(idx);
  789. -     return ListItem((ListObject *)(self), _idx);
  790. -     }
  791. -     else if (PySlice_Check(idx))
  792. -     {
  793. -     Py_ssize_t start, stop, step, slicelen;
  794. -     if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)),
  795. -                  &start, &stop, &step, &slicelen) < 0)
  796. -         return NULL;
  797. -     return ListSlice((ListObject *)(self), start, stop);
  798. -     }
  799. -     else
  800. -     {
  801. -     RAISE_INVALID_INDEX_TYPE(idx);
  802. -     return NULL;
  803. -     }
  804. - }
  805. -     static Py_ssize_t
  806. - ListAsSubscript(PyObject *self, PyObject *idx, PyObject *obj)
  807. - {
  808. -     if (PyLong_Check(idx))
  809. -     {
  810. -     long _idx = PyLong_AsLong(idx);
  811. -     return ListAssItem((ListObject *)(self), _idx, obj);
  812. -     }
  813. -     else if (PySlice_Check(idx))
  814. -     {
  815. -     Py_ssize_t start, stop, step, slicelen;
  816. -     if (PySlice_GetIndicesEx(idx, ListLength((ListObject *)(self)),
  817. -                  &start, &stop, &step, &slicelen) < 0)
  818. -         return -1;
  819. -     return ListAssSlice((ListObject *)(self), start, stop, obj);
  820. -     }
  821. -     else
  822. -     {
  823. -     RAISE_INVALID_INDEX_TYPE(idx);
  824. -     return -1;
  825. -     }
  826. - }
  827.       static PyObject *
  828.   ListGetattro(PyObject *self, PyObject *nameobj)
  829.   {
  830. --- 1482,1487 ----
  831. *** ../vim-7.4.150/src/if_python.c    2013-11-03 00:28:20.000000000 +0100
  832. --- src/if_python.c    2014-01-14 16:24:49.000000000 +0100
  833. ***************
  834. *** 196,201 ****
  835. --- 196,202 ----
  836.   # define PyTuple_Size dll_PyTuple_Size
  837.   # define PyTuple_GetItem dll_PyTuple_GetItem
  838.   # define PyTuple_Type (*dll_PyTuple_Type)
  839. + # define PySlice_GetIndicesEx dll_PySlice_GetIndicesEx
  840.   # define PyImport_ImportModule dll_PyImport_ImportModule
  841.   # define PyDict_New dll_PyDict_New
  842.   # define PyDict_GetItemString dll_PyDict_GetItemString
  843. ***************
  844. *** 241,246 ****
  845. --- 242,248 ----
  846.   # define PySys_GetObject dll_PySys_GetObject
  847.   # define PySys_SetArgv dll_PySys_SetArgv
  848.   # define PyType_Type (*dll_PyType_Type)
  849. + # define PySlice_Type (*dll_PySlice_Type)
  850.   # define PyType_Ready (*dll_PyType_Ready)
  851.   # define PyType_GenericAlloc dll_PyType_GenericAlloc
  852.   # define Py_BuildValue dll_Py_BuildValue
  853. ***************
  854. *** 341,346 ****
  855. --- 343,351 ----
  856.   static PyInt(*dll_PyTuple_Size)(PyObject *);
  857.   static PyObject*(*dll_PyTuple_GetItem)(PyObject *, PyInt);
  858.   static PyTypeObject* dll_PyTuple_Type;
  859. + static int (*dll_PySlice_GetIndicesEx)(PyObject *r, PyInt length,
  860. +              PyInt *start, PyInt *stop, PyInt *step,
  861. +              PyInt *slicelen);
  862.   static PyObject*(*dll_PyImport_ImportModule)(const char *);
  863.   static PyObject*(*dll_PyDict_New)(void);
  864.   static PyObject*(*dll_PyDict_GetItemString)(PyObject *, const char *);
  865. ***************
  866. *** 382,387 ****
  867. --- 387,393 ----
  868.   static PyObject *(*dll_PySys_GetObject)(char *);
  869.   static int(*dll_PySys_SetArgv)(int, char **);
  870.   static PyTypeObject* dll_PyType_Type;
  871. + static PyTypeObject* dll_PySlice_Type;
  872.   static int (*dll_PyType_Ready)(PyTypeObject *type);
  873.   static PyObject* (*dll_PyType_GenericAlloc)(PyTypeObject *type, PyInt nitems);
  874.   static PyObject*(*dll_Py_BuildValue)(char *, ...);
  875. ***************
  876. *** 521,526 ****
  877. --- 527,533 ----
  878.       {"PyTuple_GetItem", (PYTHON_PROC*)&dll_PyTuple_GetItem},
  879.       {"PyTuple_Size", (PYTHON_PROC*)&dll_PyTuple_Size},
  880.       {"PyTuple_Type", (PYTHON_PROC*)&dll_PyTuple_Type},
  881. +     {"PySlice_GetIndicesEx", (PYTHON_PROC*)&dll_PySlice_GetIndicesEx},
  882.       {"PyImport_ImportModule", (PYTHON_PROC*)&dll_PyImport_ImportModule},
  883.       {"PyDict_GetItemString", (PYTHON_PROC*)&dll_PyDict_GetItemString},
  884.       {"PyDict_Next", (PYTHON_PROC*)&dll_PyDict_Next},
  885. ***************
  886. *** 562,567 ****
  887. --- 569,575 ----
  888.       {"PySys_GetObject", (PYTHON_PROC*)&dll_PySys_GetObject},
  889.       {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
  890.       {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
  891. +     {"PySlice_Type", (PYTHON_PROC*)&dll_PySlice_Type},
  892.       {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
  893.       {"PyType_GenericAlloc", (PYTHON_PROC*)&dll_PyType_GenericAlloc},
  894.       {"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
  895. ***************
  896. *** 1472,1492 ****
  897.       return Py_FindMethod(DictionaryMethods, self, name);
  898.   }
  899.   
  900. - static PySequenceMethods ListAsSeq = {
  901. -     (PyInquiry)            ListLength,
  902. -     (binaryfunc)        0,
  903. -     (PyIntArgFunc)        0,
  904. -     (PyIntArgFunc)        ListItem,
  905. -     (PyIntIntArgFunc)        ListSlice,
  906. -     (PyIntObjArgProc)        ListAssItem,
  907. -     (PyIntIntObjArgProc)    ListAssSlice,
  908. -     (objobjproc)        0,
  909. - #if PY_MAJOR_VERSION >= 2
  910. -     (binaryfunc)        ListConcatInPlace,
  911. -     0,
  912. - #endif
  913. - };
  914.       static PyObject *
  915.   ListGetattr(PyObject *self, char *name)
  916.   {
  917. --- 1480,1485 ----
  918. *** ../vim-7.4.150/src/proto/eval.pro    2013-08-10 13:37:09.000000000 +0200
  919. --- src/proto/eval.pro    2014-01-14 16:24:49.000000000 +0100
  920. ***************
  921. *** 60,65 ****
  922. --- 60,66 ----
  923.   int list_append_string __ARGS((list_T *l, char_u *str, int len));
  924.   int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
  925.   void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
  926. + void list_insert __ARGS((list_T *l, listitem_T *ni, listitem_T *item));
  927.   int garbage_collect __ARGS((void));
  928.   void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
  929.   void set_ref_in_list __ARGS((list_T *l, int copyID));
  930. *** ../vim-7.4.150/src/testdir/test86.in    2013-11-28 17:04:38.000000000 +0100
  931. --- src/testdir/test86.in    2014-01-14 16:24:49.000000000 +0100
  932. ***************
  933. *** 135,140 ****
  934. --- 135,152 ----
  935.   :py l=vim.bindeval('l')
  936.   :py del l[-6:2]
  937.   :$put =string(l)
  938. + :let l = [0, 1, 2, 3]
  939. + :py l=vim.bindeval('l')
  940. + :py del l[::2]
  941. + :$put =string(l)
  942. + :let l = [0, 1, 2, 3]
  943. + :py l=vim.bindeval('l')
  944. + :py del l[3:0:-2]
  945. + :$put =string(l)
  946. + :let l = [0, 1, 2, 3]
  947. + :py l=vim.bindeval('l')
  948. + :py del l[2:4:-2]
  949. + :$put =string(l)
  950.   :"
  951.   :" Slice assignment to a list
  952.   :let l = [0, 1, 2, 3]
  953. ***************
  954. *** 169,174 ****
  955. --- 181,206 ----
  956.   :py l=vim.bindeval('l')
  957.   :py l[0:0]=['h']
  958.   :$put =string(l)
  959. + :let l = range(8)
  960. + :py l=vim.bindeval('l')
  961. + :py l[2:6:2] = [10, 20]
  962. + :$put =string(l)
  963. + :let l = range(8)
  964. + :py l=vim.bindeval('l')
  965. + :py l[6:2:-2] = [10, 20]
  966. + :$put =string(l)
  967. + :let l = range(8)
  968. + :py l=vim.bindeval('l')
  969. + :py l[6:2] = ()
  970. + :$put =string(l)
  971. + :let l = range(8)
  972. + :py l=vim.bindeval('l')
  973. + :py l[6:2:1] = ()
  974. + :$put =string(l)
  975. + :let l = range(8)
  976. + :py l=vim.bindeval('l')
  977. + :py l[2:2:1] = ()
  978. + :$put =string(l)
  979.   :"
  980.   :" Locked variables
  981.   :let l = [0, 1, 2, 3]
  982. ***************
  983. *** 390,395 ****
  984. --- 422,434 ----
  985.   :$put =string(pyeval('l'))
  986.   :py l = ll[-10:10]
  987.   :$put =string(pyeval('l'))
  988. + :py l = ll[4:2:-1]
  989. + :$put =string(pyeval('l'))
  990. + :py l = ll[::2]
  991. + :$put =string(pyeval('l'))
  992. + :py l = ll[4:2:1]
  993. + :$put =string(pyeval('l'))
  994. + :py del l
  995.   :"
  996.   :" Vars
  997.   :let g:foo = 'bac'
  998. ***************
  999. *** 907,912 ****
  1000. --- 946,952 ----
  1001.   l = vim.List()
  1002.   ll = vim.List('abcE')
  1003.   ll.locked = True
  1004. + nel = vim.List('abcO')
  1005.   f = vim.Function('string')
  1006.   fd = vim.Function('F')
  1007.   fdel = vim.Function('D')
  1008. ***************
  1009. *** 994,999 ****
  1010. --- 1034,1053 ----
  1011.       def next(self):
  1012.           raise NotImplementedError('next')
  1013.   
  1014. + class FailingIterNextN(object):
  1015. +     def __init__(self, n):
  1016. +         self.n = n
  1017. +     def __iter__(self):
  1018. +         return self
  1019. +     def next(self):
  1020. +         if self.n:
  1021. +             self.n -= 1
  1022. +             return 1
  1023. +         else:
  1024. +             raise NotImplementedError('next N')
  1025.   class FailingMappingKey(object):
  1026.       def __getitem__(self, item):
  1027.           raise NotImplementedError('getitem:mappingkey')
  1028. ***************
  1029. *** 1098,1103 ****
  1030. --- 1152,1158 ----
  1031.   cb.append(">>> iter")
  1032.   ee('d.update(FailingMapping())')
  1033.   ee('d.update([FailingIterNext()])')
  1034. + ee('d.update([FailingIterNextN(1)])')
  1035.   iter_test('d.update(%s)')
  1036.   convertfrompyobject_test('d.update(%s)')
  1037.   stringtochars_test('d.update(((%s, 0),))')
  1038. ***************
  1039. *** 1120,1125 ****
  1040. --- 1175,1188 ----
  1041.   cb.append(">> ListAssSlice")
  1042.   ee('ll[1:100] = "abcJ"')
  1043.   iter_test('l[:] = %s')
  1044. + ee('nel[1:10:2]  = "abcK"')
  1045. + cb.append(repr(tuple(nel)))
  1046. + ee('nel[1:10:2]  = "a"')
  1047. + cb.append(repr(tuple(nel)))
  1048. + ee('nel[1:1:-1]  = "a"')
  1049. + cb.append(repr(tuple(nel)))
  1050. + ee('nel[:] = FailingIterNextN(2)')
  1051. + cb.append(repr(tuple(nel)))
  1052.   convertfrompyobject_test('l[:] = [%s]')
  1053.   cb.append(">> ListConcatInPlace")
  1054.   iter_test('l.extend(%s)')
  1055. ***************
  1056. *** 1201,1206 ****
  1057. --- 1264,1270 ----
  1058.   del dl
  1059.   del l
  1060.   del ll
  1061. + del nel
  1062.   del f
  1063.   del fd
  1064.   del fdel
  1065. ***************
  1066. *** 1214,1219 ****
  1067. --- 1278,1284 ----
  1068.   del FailingTrue
  1069.   del FailingIter
  1070.   del FailingIterNext
  1071. + del FailingIterNextN
  1072.   del FailingMapping
  1073.   del FailingMappingKey
  1074.   del FailingList
  1075. *** ../vim-7.4.150/src/testdir/test86.ok    2013-11-28 17:04:38.000000000 +0100
  1076. --- src/testdir/test86.ok    2014-01-14 16:24:49.000000000 +0100
  1077. ***************
  1078. *** 41,46 ****
  1079. --- 41,49 ----
  1080.   [2, 3]
  1081.   [2, 3]
  1082.   [2, 3]
  1083. + [1, 3]
  1084. + [0, 2]
  1085. + [0, 1, 2, 3]
  1086.   ['a', 0, 1, 2, 3]
  1087.   [0, 'b', 2, 3]
  1088.   [0, 1, 'c']
  1089. ***************
  1090. *** 49,54 ****
  1091. --- 52,62 ----
  1092.   ['f', 2, 3]
  1093.   [0, 1, 'g', 2, 3]
  1094.   ['h']
  1095. + [0, 1, 10, 3, 20, 5, 6, 7]
  1096. + [0, 1, 2, 3, 20, 5, 10, 7]
  1097. + [0, 1, 2, 3, 4, 5, 6, 7]
  1098. + [0, 1, 2, 3, 4, 5, 6, 7]
  1099. + [0, 1, 2, 3, 4, 5, 6, 7]
  1100.   [0, 1, 2, 3]
  1101.   [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
  1102.   [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
  1103. ***************
  1104. *** 96,101 ****
  1105. --- 104,112 ----
  1106.   [0, 1, 2, 3, 4, 5]
  1107.   [0, 1, 2, 3, 4, 5]
  1108.   [0, 1, 2, 3, 4, 5]
  1109. + [4, 3]
  1110. + [0, 2, 4]
  1111. + []
  1112.   Abc
  1113.   bac
  1114.   def
  1115. ***************
  1116. *** 599,604 ****
  1117. --- 610,616 ----
  1118.   >>> iter
  1119.   d.update(FailingMapping()):NotImplementedError:('keys',)
  1120.   d.update([FailingIterNext()]):NotImplementedError:('next',)
  1121. + d.update([FailingIterNextN(1)]):NotImplementedError:('next N',)
  1122.   >>> Testing *Iter* using d.update(%s)
  1123.   d.update(FailingIter()):NotImplementedError:('iter',)
  1124.   d.update(FailingIterNext()):NotImplementedError:('next',)
  1125. ***************
  1126. *** 829,834 ****
  1127. --- 841,854 ----
  1128.   l[:] = FailingIter():NotImplementedError:('iter',)
  1129.   l[:] = FailingIterNext():NotImplementedError:('next',)
  1130.   <<< Finished
  1131. + nel[1:10:2]  = "abcK":ValueError:('attempt to assign sequence of size greater then 2 to extended slice',)
  1132. + ('a', 'b', 'c', 'O')
  1133. + nel[1:10:2]  = "a":ValueError:('attempt to assign sequence of size 1 to extended slice of size 2',)
  1134. + ('a', 'b', 'c', 'O')
  1135. + nel[1:1:-1]  = "a":ValueError:('attempt to assign sequence of size greater then 0 to extended slice',)
  1136. + ('a', 'b', 'c', 'O')
  1137. + nel[:] = FailingIterNextN(2):NotImplementedError:('next N',)
  1138. + ('a', 'b', 'c', 'O')
  1139.   >>> Testing StringToChars using l[:] = [{%s : 1}]
  1140.   l[:] = [{1 : 1}]:TypeError:('expected str() or unicode() instance, but got int',)
  1141.   l[:] = [{u"\0" : 1}]:TypeError:('expected string without null bytes',)
  1142. *** ../vim-7.4.150/src/testdir/test87.in    2013-11-28 17:04:38.000000000 +0100
  1143. --- src/testdir/test87.in    2014-01-14 16:24:49.000000000 +0100
  1144. ***************
  1145. *** 128,133 ****
  1146. --- 128,145 ----
  1147.   :py3 l=vim.bindeval('l')
  1148.   :py3 del l[-6:2]
  1149.   :$put =string(l)
  1150. + :let l = [0, 1, 2, 3]
  1151. + :py3 l=vim.bindeval('l')
  1152. + :py3 del l[::2]
  1153. + :$put =string(l)
  1154. + :let l = [0, 1, 2, 3]
  1155. + :py3 l=vim.bindeval('l')
  1156. + :py3 del l[3:0:-2]
  1157. + :$put =string(l)
  1158. + :let l = [0, 1, 2, 3]
  1159. + :py3 l=vim.bindeval('l')
  1160. + :py3 del l[2:4:-2]
  1161. + :$put =string(l)
  1162.   :"
  1163.   :" Slice assignment to a list
  1164.   :let l = [0, 1, 2, 3]
  1165. ***************
  1166. *** 162,167 ****
  1167. --- 174,199 ----
  1168.   :py3 l=vim.bindeval('l')
  1169.   :py3 l[0:0]=['h']
  1170.   :$put =string(l)
  1171. + :let l = range(8)
  1172. + :py3 l=vim.bindeval('l')
  1173. + :py3 l[2:6:2] = [10, 20]
  1174. + :$put =string(l)
  1175. + :let l = range(8)
  1176. + :py3 l=vim.bindeval('l')
  1177. + :py3 l[6:2:-2] = [10, 20]
  1178. + :$put =string(l)
  1179. + :let l = range(8)
  1180. + :py3 l=vim.bindeval('l')
  1181. + :py3 l[6:2] = ()
  1182. + :$put =string(l)
  1183. + :let l = range(8)
  1184. + :py3 l=vim.bindeval('l')
  1185. + :py3 l[6:2:1] = ()
  1186. + :$put =string(l)
  1187. + :let l = range(8)
  1188. + :py3 l=vim.bindeval('l')
  1189. + :py3 l[2:2:1] = ()
  1190. + :$put =string(l)
  1191.   :"
  1192.   :" Locked variables
  1193.   :let l = [0, 1, 2, 3]
  1194. ***************
  1195. *** 363,368 ****
  1196. --- 395,432 ----
  1197.   :py3 del trace_main
  1198.   :$put =string(l)
  1199.   :"
  1200. + :" Slice
  1201. + :py3 ll = vim.bindeval('[0, 1, 2, 3, 4, 5]')
  1202. + :py3 l = ll[:4]
  1203. + :$put =string(py3eval('l'))
  1204. + :py3 l = ll[2:]
  1205. + :$put =string(py3eval('l'))
  1206. + :py3 l = ll[:-4]
  1207. + :$put =string(py3eval('l'))
  1208. + :py3 l = ll[-2:]
  1209. + :$put =string(py3eval('l'))
  1210. + :py3 l = ll[2:4]
  1211. + :$put =string(py3eval('l'))
  1212. + :py3 l = ll[4:2]
  1213. + :$put =string(py3eval('l'))
  1214. + :py3 l = ll[-4:-2]
  1215. + :$put =string(py3eval('l'))
  1216. + :py3 l = ll[-2:-4]
  1217. + :$put =string(py3eval('l'))
  1218. + :py3 l = ll[:]
  1219. + :$put =string(py3eval('l'))
  1220. + :py3 l = ll[0:6]
  1221. + :$put =string(py3eval('l'))
  1222. + :py3 l = ll[-10:10]
  1223. + :$put =string(py3eval('l'))
  1224. + :py3 l = ll[4:2:-1]
  1225. + :$put =string(py3eval('l'))
  1226. + :py3 l = ll[::2]
  1227. + :$put =string(py3eval('l'))
  1228. + :py3 l = ll[4:2:1]
  1229. + :$put =string(py3eval('l'))
  1230. + :py3 del l
  1231. + :"
  1232.   :" Vars
  1233.   :let g:foo = 'bac'
  1234.   :let w:abc3 = 'def'
  1235. ***************
  1236. *** 859,864 ****
  1237. --- 923,929 ----
  1238.   l = vim.List()
  1239.   ll = vim.List('abcE')
  1240.   ll.locked = True
  1241. + nel = vim.List('abcO')
  1242.   f = vim.Function('string')
  1243.   fd = vim.Function('F')
  1244.   fdel = vim.Function('D')
  1245. ***************
  1246. *** 946,951 ****
  1247. --- 1011,1030 ----
  1248.       def __next__(self):
  1249.           raise NotImplementedError('next')
  1250.   
  1251. + class FailingIterNextN(object):
  1252. +     def __init__(self, n):
  1253. +         self.n = n
  1254. +     def __iter__(self):
  1255. +         return self
  1256. +     def __next__(self):
  1257. +         if self.n:
  1258. +             self.n -= 1
  1259. +             return 1
  1260. +         else:
  1261. +             raise NotImplementedError('next N')
  1262.   class FailingMappingKey(object):
  1263.       def __getitem__(self, item):
  1264.           raise NotImplementedError('getitem:mappingkey')
  1265. ***************
  1266. *** 1050,1055 ****
  1267. --- 1129,1135 ----
  1268.   cb.append(">>> iter")
  1269.   ee('d.update(FailingMapping())')
  1270.   ee('d.update([FailingIterNext()])')
  1271. + ee('d.update([FailingIterNextN(1)])')
  1272.   iter_test('d.update(%s)')
  1273.   convertfrompyobject_test('d.update(%s)')
  1274.   stringtochars_test('d.update(((%s, 0),))')
  1275. ***************
  1276. *** 1072,1077 ****
  1277. --- 1152,1165 ----
  1278.   cb.append(">> ListAssSlice")
  1279.   ee('ll[1:100] = "abcJ"')
  1280.   iter_test('l[:] = %s')
  1281. + ee('nel[1:10:2]  = "abcK"')
  1282. + cb.append(repr(tuple(nel)))
  1283. + ee('nel[1:10:2]  = "a"')
  1284. + cb.append(repr(tuple(nel)))
  1285. + ee('nel[1:1:-1]  = "a"')
  1286. + cb.append(repr(tuple(nel)))
  1287. + ee('nel[:] = FailingIterNextN(2)')
  1288. + cb.append(repr(tuple(nel)))
  1289.   convertfrompyobject_test('l[:] = [%s]')
  1290.   cb.append(">> ListConcatInPlace")
  1291.   iter_test('l.extend(%s)')
  1292. ***************
  1293. *** 1153,1158 ****
  1294. --- 1241,1247 ----
  1295.   del dl
  1296.   del l
  1297.   del ll
  1298. + del nel
  1299.   del f
  1300.   del fd
  1301.   del fdel
  1302. ***************
  1303. *** 1166,1171 ****
  1304. --- 1255,1261 ----
  1305.   del FailingTrue
  1306.   del FailingIter
  1307.   del FailingIterNext
  1308. + del FailingIterNextN
  1309.   del FailingMapping
  1310.   del FailingMappingKey
  1311.   del FailingList
  1312. *** ../vim-7.4.150/src/testdir/test87.ok    2013-11-28 17:04:38.000000000 +0100
  1313. --- src/testdir/test87.ok    2014-01-14 16:24:49.000000000 +0100
  1314. ***************
  1315. *** 41,46 ****
  1316. --- 41,49 ----
  1317.   [2, 3]
  1318.   [2, 3]
  1319.   [2, 3]
  1320. + [1, 3]
  1321. + [0, 2]
  1322. + [0, 1, 2, 3]
  1323.   ['a', 0, 1, 2, 3]
  1324.   [0, 'b', 2, 3]
  1325.   [0, 1, 'c']
  1326. ***************
  1327. *** 49,54 ****
  1328. --- 52,62 ----
  1329.   ['f', 2, 3]
  1330.   [0, 1, 'g', 2, 3]
  1331.   ['h']
  1332. + [0, 1, 10, 3, 20, 5, 6, 7]
  1333. + [0, 1, 2, 3, 20, 5, 10, 7]
  1334. + [0, 1, 2, 3, 4, 5, 6, 7]
  1335. + [0, 1, 2, 3, 4, 5, 6, 7]
  1336. + [0, 1, 2, 3, 4, 5, 6, 7]
  1337.   [0, 1, 2, 3]
  1338.   [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd']
  1339.   [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}]
  1340. ***************
  1341. *** 85,90 ****
  1342. --- 93,112 ----
  1343.   vim:    Vim(let):E859:
  1344.   [1]
  1345.   [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]
  1346. + [0, 1, 2, 3]
  1347. + [2, 3, 4, 5]
  1348. + [0, 1]
  1349. + [4, 5]
  1350. + [2, 3]
  1351. + []
  1352. + [2, 3]
  1353. + []
  1354. + [0, 1, 2, 3, 4, 5]
  1355. + [0, 1, 2, 3, 4, 5]
  1356. + [0, 1, 2, 3, 4, 5]
  1357. + [4, 3]
  1358. + [0, 2, 4]
  1359. + []
  1360.   Abc
  1361.   bac
  1362.   def
  1363. ***************
  1364. *** 588,593 ****
  1365. --- 610,616 ----
  1366.   >>> iter
  1367.   d.update(FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',))
  1368.   d.update([FailingIterNext()]):(<class 'NotImplementedError'>, NotImplementedError('next',))
  1369. + d.update([FailingIterNextN(1)]):(<class 'NotImplementedError'>, NotImplementedError('next N',))
  1370.   >>> Testing *Iter* using d.update(%s)
  1371.   d.update(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',))
  1372.   d.update(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',))
  1373. ***************
  1374. *** 818,823 ****
  1375. --- 841,854 ----
  1376.   l[:] = FailingIter():(<class 'NotImplementedError'>, NotImplementedError('iter',))
  1377.   l[:] = FailingIterNext():(<class 'NotImplementedError'>, NotImplementedError('next',))
  1378.   <<< Finished
  1379. + nel[1:10:2]  = "abcK":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater then 2 to extended slice',))
  1380. + (b'a', b'b', b'c', b'O')
  1381. + nel[1:10:2]  = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size 1 to extended slice of size 2',))
  1382. + (b'a', b'b', b'c', b'O')
  1383. + nel[1:1:-1]  = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater then 0 to extended slice',))
  1384. + (b'a', b'b', b'c', b'O')
  1385. + nel[:] = FailingIterNextN(2):(<class 'NotImplementedError'>, NotImplementedError('next N',))
  1386. + (b'a', b'b', b'c', b'O')
  1387.   >>> Testing StringToChars using l[:] = [{%s : 1}]
  1388.   l[:] = [{1 : 1}]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
  1389.   l[:] = [{b"\0" : 1}]:(<class 'TypeError'>, TypeError('expected bytes with no null',))
  1390. *** ../vim-7.4.150/src/version.c    2014-01-14 15:53:47.000000000 +0100
  1391. --- src/version.c    2014-01-14 16:27:01.000000000 +0100
  1392. ***************
  1393. *** 740,741 ****
  1394. --- 740,743 ----
  1395.   {   /* Add new patch number below this line */
  1396. + /**/
  1397. +     151,
  1398.   /**/
  1399.  
  1400. -- 
  1401. hundred-and-one symptoms of being an internet addict:
  1402. 159. You get excited whenever discussing your hard drive.
  1403.  
  1404.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  1405. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  1406. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  1407.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  1408.