|
Karsten Hopp |
b3807e |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
b3807e |
Subject: Patch 7.3.1062
|
|
Karsten Hopp |
b3807e |
Fcc: outbox
|
|
Karsten Hopp |
b3807e |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
b3807e |
Mime-Version: 1.0
|
|
Karsten Hopp |
b3807e |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
b3807e |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
b3807e |
------------
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
Patch 7.3.1062
|
|
Karsten Hopp |
b3807e |
Problem: Python: List is not standard.
|
|
Karsten Hopp |
b3807e |
Solution: Python patch 21: Add standard methods and fields. (ZyX)
|
|
Karsten Hopp |
b3807e |
Files: src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
|
|
Karsten Hopp |
b3807e |
src/testdir/test87.in, src/testdir/test87.ok
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/if_py_both.h 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/if_py_both.h 2013-05-30 13:03:54.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1530,1541 ****
|
|
Karsten Hopp |
b3807e |
pylinkedlist_T ref;
|
|
Karsten Hopp |
b3807e |
} ListObject;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
static PyObject *
|
|
Karsten Hopp |
b3807e |
! ListNew(list_T *list)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
ListObject *self;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! self = PyObject_NEW(ListObject, &ListType);
|
|
Karsten Hopp |
b3807e |
if (self == NULL)
|
|
Karsten Hopp |
b3807e |
return NULL;
|
|
Karsten Hopp |
b3807e |
self->list = list;
|
|
Karsten Hopp |
b3807e |
--- 1530,1543 ----
|
|
Karsten Hopp |
b3807e |
pylinkedlist_T ref;
|
|
Karsten Hopp |
b3807e |
} ListObject;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
+ #define NEW_LIST(list) ListNew(&ListType, list)
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
static PyObject *
|
|
Karsten Hopp |
b3807e |
! ListNew(PyTypeObject *subtype, list_T *list)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
ListObject *self;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! self = (ListObject *) subtype->tp_alloc(subtype, 0);
|
|
Karsten Hopp |
b3807e |
if (self == NULL)
|
|
Karsten Hopp |
b3807e |
return NULL;
|
|
Karsten Hopp |
b3807e |
self->list = list;
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1546,1589 ****
|
|
Karsten Hopp |
b3807e |
return (PyObject *)(self);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! static void
|
|
Karsten Hopp |
b3807e |
! ListDestructor(ListObject *self)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! pyll_remove(&self->ref, &lastlist);
|
|
Karsten Hopp |
b3807e |
! list_unref(self->list);
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
static int
|
|
Karsten Hopp |
b3807e |
list_py_concat(list_T *l, PyObject *obj, PyObject *lookup_dict)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! Py_ssize_t i;
|
|
Karsten Hopp |
b3807e |
! Py_ssize_t lsize = PySequence_Size(obj);
|
|
Karsten Hopp |
b3807e |
! PyObject *litem;
|
|
Karsten Hopp |
b3807e |
listitem_T *li;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! for(i=0; i
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! li = listitem_alloc();
|
|
Karsten Hopp |
b3807e |
! if (li == NULL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyErr_NoMemory();
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
li->li_tv.v_lock = 0;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! litem = PySequence_GetItem(obj, i);
|
|
Karsten Hopp |
b3807e |
! if (litem == NULL)
|
|
Karsten Hopp |
b3807e |
! return -1;
|
|
Karsten Hopp |
b3807e |
! if (_ConvertFromPyObject(litem, &li->li_tv, lookup_dict) == -1)
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
list_append(l, li);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
static PyInt
|
|
Karsten Hopp |
b3807e |
ListLength(ListObject *self)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
--- 1548,1663 ----
|
|
Karsten Hopp |
b3807e |
return (PyObject *)(self);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! static list_T *
|
|
Karsten Hopp |
b3807e |
! py_list_alloc()
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! list_T *r;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! if (!(r = list_alloc()))
|
|
Karsten Hopp |
b3807e |
! {
|
|
Karsten Hopp |
b3807e |
! PyErr_NoMemory();
|
|
Karsten Hopp |
b3807e |
! return NULL;
|
|
Karsten Hopp |
b3807e |
! }
|
|
Karsten Hopp |
b3807e |
! ++r->lv_refcount;
|
|
Karsten Hopp |
b3807e |
!
|
|
Karsten Hopp |
b3807e |
! return r;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
static int
|
|
Karsten Hopp |
b3807e |
list_py_concat(list_T *l, PyObject *obj, PyObject *lookup_dict)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! PyObject *iterator;
|
|
Karsten Hopp |
b3807e |
! PyObject *item;
|
|
Karsten Hopp |
b3807e |
listitem_T *li;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! if (!(iterator = PyObject_GetIter(obj)))
|
|
Karsten Hopp |
b3807e |
! return -1;
|
|
Karsten Hopp |
b3807e |
!
|
|
Karsten Hopp |
b3807e |
! while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! if (!(li = listitem_alloc()))
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyErr_NoMemory();
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
li->li_tv.v_lock = 0;
|
|
Karsten Hopp |
b3807e |
+ li->li_tv.v_type = VAR_UNKNOWN;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! if (_ConvertFromPyObject(item, &li->li_tv, lookup_dict) == -1)
|
|
Karsten Hopp |
b3807e |
! {
|
|
Karsten Hopp |
b3807e |
! Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
! Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
! listitem_free(li);
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
list_append(l, li);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ /* Iterator may have finished due to an exception */
|
|
Karsten Hopp |
b3807e |
+ if (PyErr_Occurred())
|
|
Karsten Hopp |
b3807e |
+ return -1;
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
+ static PyObject *
|
|
Karsten Hopp |
b3807e |
+ ListConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ list_T *list;
|
|
Karsten Hopp |
b3807e |
+ PyObject *obj = NULL;
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (kwargs)
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ PyErr_SetString(PyExc_TypeError,
|
|
Karsten Hopp |
b3807e |
+ _("list constructor does not accept keyword arguments"));
|
|
Karsten Hopp |
b3807e |
+ return NULL;
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (!PyArg_ParseTuple(args, "|O", &obj))
|
|
Karsten Hopp |
b3807e |
+ return NULL;
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (!(list = py_list_alloc()))
|
|
Karsten Hopp |
b3807e |
+ return NULL;
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (obj)
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ PyObject *lookup_dict;
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (!(lookup_dict = PyDict_New()))
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ list_unref(list);
|
|
Karsten Hopp |
b3807e |
+ return NULL;
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ if (list_py_concat(list, obj, lookup_dict) == -1)
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(lookup_dict);
|
|
Karsten Hopp |
b3807e |
+ list_unref(list);
|
|
Karsten Hopp |
b3807e |
+ return NULL;
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(lookup_dict);
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ return ListNew(subtype, list);
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ static void
|
|
Karsten Hopp |
b3807e |
+ ListDestructor(ListObject *self)
|
|
Karsten Hopp |
b3807e |
+ {
|
|
Karsten Hopp |
b3807e |
+ pyll_remove(&self->ref, &lastlist);
|
|
Karsten Hopp |
b3807e |
+ list_unref(self->list);
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
static PyInt
|
|
Karsten Hopp |
b3807e |
ListLength(ListObject *self)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1747,1753 ****
|
|
Karsten Hopp |
b3807e |
if (list_append_tv(l, &tv) == FAIL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
clear_tv(&tv;;
|
|
Karsten Hopp |
b3807e |
! PyErr_SetVim(_("Failed to add item to list"));
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
--- 1821,1827 ----
|
|
Karsten Hopp |
b3807e |
if (list_append_tv(l, &tv) == FAIL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
clear_tv(&tv;;
|
|
Karsten Hopp |
b3807e |
! PyErr_SetVim(_("failed to add item to list"));
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1765,1777 ****
|
|
Karsten Hopp |
b3807e |
ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyInt size = ListLength(self);
|
|
Karsten Hopp |
b3807e |
! Py_ssize_t i;
|
|
Karsten Hopp |
b3807e |
! Py_ssize_t lsize;
|
|
Karsten Hopp |
b3807e |
! PyObject *litem;
|
|
Karsten Hopp |
b3807e |
listitem_T *li;
|
|
Karsten Hopp |
b3807e |
listitem_T *next;
|
|
Karsten Hopp |
b3807e |
typval_T v;
|
|
Karsten Hopp |
b3807e |
list_T *l = self->list;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
if (l->lv_lock)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
--- 1839,1851 ----
|
|
Karsten Hopp |
b3807e |
ListAssSlice(ListObject *self, Py_ssize_t first, Py_ssize_t last, PyObject *obj)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyInt size = ListLength(self);
|
|
Karsten Hopp |
b3807e |
! PyObject *iterator;
|
|
Karsten Hopp |
b3807e |
! PyObject *item;
|
|
Karsten Hopp |
b3807e |
listitem_T *li;
|
|
Karsten Hopp |
b3807e |
listitem_T *next;
|
|
Karsten Hopp |
b3807e |
typval_T v;
|
|
Karsten Hopp |
b3807e |
list_T *l = self->list;
|
|
Karsten Hopp |
b3807e |
+ PyInt i;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
if (l->lv_lock)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1806,1826 ****
|
|
Karsten Hopp |
b3807e |
if (obj == NULL)
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! if (!PyList_Check(obj))
|
|
Karsten Hopp |
b3807e |
! {
|
|
Karsten Hopp |
b3807e |
! PyErr_SetString(PyExc_TypeError, _("can only assign lists to slice"));
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- lsize = PyList_Size(obj);
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! for(i=0; i
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! litem = PyList_GetItem(obj, i);
|
|
Karsten Hopp |
b3807e |
! if (litem == NULL)
|
|
Karsten Hopp |
b3807e |
! return -1;
|
|
Karsten Hopp |
b3807e |
! if (ConvertFromPyObject(litem, &v) == -1)
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
if (list_insert_tv(l, &v, li) == FAIL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
clear_tv(&v);
|
|
Karsten Hopp |
b3807e |
--- 1880,1897 ----
|
|
Karsten Hopp |
b3807e |
if (obj == NULL)
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! if (!(iterator = PyObject_GetIter(obj)))
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
! while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
! if (ConvertFromPyObject(item, &v) == -1)
|
|
Karsten Hopp |
b3807e |
! {
|
|
Karsten Hopp |
b3807e |
! Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
! Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
+ }
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
if (list_insert_tv(l, &v, li) == FAIL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
clear_tv(&v);
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1829,1834 ****
|
|
Karsten Hopp |
b3807e |
--- 1900,1906 ----
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
clear_tv(&v);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1844,1855 ****
|
|
Karsten Hopp |
b3807e |
return NULL;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
- if (!PySequence_Check(obj))
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- PyErr_SetString(PyExc_TypeError, _("can only concatenate with lists"));
|
|
Karsten Hopp |
b3807e |
- return NULL;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
if (!(lookup_dict = PyDict_New()))
|
|
Karsten Hopp |
b3807e |
return NULL;
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
--- 1916,1921 ----
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 1881,1887 ****
|
|
Karsten Hopp |
b3807e |
if (val == NULL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyErr_SetString(PyExc_AttributeError,
|
|
Karsten Hopp |
b3807e |
! _("cannot delete vim.dictionary attributes"));
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
--- 1947,1953 ----
|
|
Karsten Hopp |
b3807e |
if (val == NULL)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
PyErr_SetString(PyExc_AttributeError,
|
|
Karsten Hopp |
b3807e |
! _("cannot delete vim.List attributes"));
|
|
Karsten Hopp |
b3807e |
return -1;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 4591,4611 ****
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
- static list_T *
|
|
Karsten Hopp |
b3807e |
- py_list_alloc()
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- list_T *r;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- if (!(r = list_alloc()))
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- PyErr_NoMemory();
|
|
Karsten Hopp |
b3807e |
- return NULL;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
- ++r->lv_refcount;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- return r;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
static int
|
|
Karsten Hopp |
b3807e |
pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
|
|
Karsten Hopp |
b3807e |
{
|
|
Karsten Hopp |
b3807e |
--- 4657,4662 ----
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 4627,4691 ****
|
|
Karsten Hopp |
b3807e |
return 0;
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
- static int
|
|
Karsten Hopp |
b3807e |
- pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookup_dict)
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- PyObject *iterator;
|
|
Karsten Hopp |
b3807e |
- PyObject *item;
|
|
Karsten Hopp |
b3807e |
- list_T *l;
|
|
Karsten Hopp |
b3807e |
- listitem_T *li;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- if (!(l = py_list_alloc()))
|
|
Karsten Hopp |
b3807e |
- return -1;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- tv->vval.v_list = l;
|
|
Karsten Hopp |
b3807e |
- tv->v_type = VAR_LIST;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- if (!(iterator = PyObject_GetIter(obj)))
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- list_unref(l);
|
|
Karsten Hopp |
b3807e |
- return -1;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- li = listitem_alloc();
|
|
Karsten Hopp |
b3807e |
- if (li == NULL)
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- list_unref(l);
|
|
Karsten Hopp |
b3807e |
- Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
- PyErr_NoMemory();
|
|
Karsten Hopp |
b3807e |
- return -1;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
- li->li_tv.v_lock = 0;
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- if (_ConvertFromPyObject(item, &li->li_tv, lookup_dict) == -1)
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- list_unref(l);
|
|
Karsten Hopp |
b3807e |
- listitem_free(li);
|
|
Karsten Hopp |
b3807e |
- Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
- Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
- return -1;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- list_append(l, li);
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- Py_DECREF(item);
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- Py_DECREF(iterator);
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- /* Iterator may have finished due to an exception */
|
|
Karsten Hopp |
b3807e |
- if (PyErr_Occurred())
|
|
Karsten Hopp |
b3807e |
- {
|
|
Karsten Hopp |
b3807e |
- list_unref(l);
|
|
Karsten Hopp |
b3807e |
- return -1;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
- --l->lv_refcount;
|
|
Karsten Hopp |
b3807e |
- return 0;
|
|
Karsten Hopp |
b3807e |
- }
|
|
Karsten Hopp |
b3807e |
-
|
|
Karsten Hopp |
b3807e |
typedef int (*pytotvfunc)(PyObject *, typval_T *, PyObject *);
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
static int
|
|
Karsten Hopp |
b3807e |
--- 4678,4683 ----
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 4866,4874 ****
|
|
Karsten Hopp |
b3807e |
tv->vval.v_float = (float_T) PyFloat_AsDouble(obj);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
#endif
|
|
Karsten Hopp |
b3807e |
! else if (PyIter_Check(obj))
|
|
Karsten Hopp |
b3807e |
! return convert_dl(obj, tv, pyiter_to_tv, lookup_dict);
|
|
Karsten Hopp |
b3807e |
! else if (PySequence_Check(obj))
|
|
Karsten Hopp |
b3807e |
return convert_dl(obj, tv, pyseq_to_tv, lookup_dict);
|
|
Karsten Hopp |
b3807e |
else if (PyMapping_Check(obj))
|
|
Karsten Hopp |
b3807e |
return convert_dl(obj, tv, pymap_to_tv, lookup_dict);
|
|
Karsten Hopp |
b3807e |
--- 4858,4864 ----
|
|
Karsten Hopp |
b3807e |
tv->vval.v_float = (float_T) PyFloat_AsDouble(obj);
|
|
Karsten Hopp |
b3807e |
}
|
|
Karsten Hopp |
b3807e |
#endif
|
|
Karsten Hopp |
b3807e |
! else if (PyIter_Check(obj) || PySequence_Check(obj))
|
|
Karsten Hopp |
b3807e |
return convert_dl(obj, tv, pyseq_to_tv, lookup_dict);
|
|
Karsten Hopp |
b3807e |
else if (PyMapping_Check(obj))
|
|
Karsten Hopp |
b3807e |
return convert_dl(obj, tv, pymap_to_tv, lookup_dict);
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 4901,4907 ****
|
|
Karsten Hopp |
b3807e |
return PyFloat_FromDouble((double) tv->vval.v_float);
|
|
Karsten Hopp |
b3807e |
#endif
|
|
Karsten Hopp |
b3807e |
case VAR_LIST:
|
|
Karsten Hopp |
b3807e |
! return ListNew(tv->vval.v_list);
|
|
Karsten Hopp |
b3807e |
case VAR_DICT:
|
|
Karsten Hopp |
b3807e |
return NEW_DICTIONARY(tv->vval.v_dict);
|
|
Karsten Hopp |
b3807e |
case VAR_FUNC:
|
|
Karsten Hopp |
b3807e |
--- 4891,4897 ----
|
|
Karsten Hopp |
b3807e |
return PyFloat_FromDouble((double) tv->vval.v_float);
|
|
Karsten Hopp |
b3807e |
#endif
|
|
Karsten Hopp |
b3807e |
case VAR_LIST:
|
|
Karsten Hopp |
b3807e |
! return NEW_LIST(tv->vval.v_list);
|
|
Karsten Hopp |
b3807e |
case VAR_DICT:
|
|
Karsten Hopp |
b3807e |
return NEW_DICTIONARY(tv->vval.v_dict);
|
|
Karsten Hopp |
b3807e |
case VAR_FUNC:
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 5096,5105 ****
|
|
Karsten Hopp |
b3807e |
ListType.tp_basicsize = sizeof(ListObject);
|
|
Karsten Hopp |
b3807e |
ListType.tp_as_sequence = &ListAsSeq;
|
|
Karsten Hopp |
b3807e |
ListType.tp_as_mapping = &ListAsMapping;
|
|
Karsten Hopp |
b3807e |
! ListType.tp_flags = Py_TPFLAGS_DEFAULT;
|
|
Karsten Hopp |
b3807e |
ListType.tp_doc = "list pushing modifications to vim structure";
|
|
Karsten Hopp |
b3807e |
ListType.tp_methods = ListMethods;
|
|
Karsten Hopp |
b3807e |
ListType.tp_iter = (getiterfunc)ListIter;
|
|
Karsten Hopp |
b3807e |
#if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
b3807e |
ListType.tp_getattro = (getattrofunc)ListGetattro;
|
|
Karsten Hopp |
b3807e |
ListType.tp_setattro = (setattrofunc)ListSetattro;
|
|
Karsten Hopp |
b3807e |
--- 5086,5097 ----
|
|
Karsten Hopp |
b3807e |
ListType.tp_basicsize = sizeof(ListObject);
|
|
Karsten Hopp |
b3807e |
ListType.tp_as_sequence = &ListAsSeq;
|
|
Karsten Hopp |
b3807e |
ListType.tp_as_mapping = &ListAsMapping;
|
|
Karsten Hopp |
b3807e |
! ListType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE;
|
|
Karsten Hopp |
b3807e |
ListType.tp_doc = "list pushing modifications to vim structure";
|
|
Karsten Hopp |
b3807e |
ListType.tp_methods = ListMethods;
|
|
Karsten Hopp |
b3807e |
ListType.tp_iter = (getiterfunc)ListIter;
|
|
Karsten Hopp |
b3807e |
+ ListType.tp_new = (newfunc)ListConstructor;
|
|
Karsten Hopp |
b3807e |
+ ListType.tp_alloc = (allocfunc)PyType_GenericAlloc;
|
|
Karsten Hopp |
b3807e |
#if PY_MAJOR_VERSION >= 3
|
|
Karsten Hopp |
b3807e |
ListType.tp_getattro = (getattrofunc)ListGetattro;
|
|
Karsten Hopp |
b3807e |
ListType.tp_setattro = (setattrofunc)ListSetattro;
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/testdir/test86.in 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/testdir/test86.in 2013-05-30 13:03:54.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 735,740 ****
|
|
Karsten Hopp |
b3807e |
--- 735,742 ----
|
|
Karsten Hopp |
b3807e |
:$put =string(pyeval('vim.Dictionary({})'))
|
|
Karsten Hopp |
b3807e |
:$put =string(pyeval('vim.Dictionary(a=1)'))
|
|
Karsten Hopp |
b3807e |
:$put =string(pyeval('vim.Dictionary(((''a'', 1),))'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(pyeval('vim.List()'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(pyeval('vim.List(iter(''abc''))'))
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
:" Test stdout/stderr
|
|
Karsten Hopp |
b3807e |
:redir => messages
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 752,759 ****
|
|
Karsten Hopp |
b3807e |
--- 754,771 ----
|
|
Karsten Hopp |
b3807e |
super(DupDict, self).__setitem__('dup_' + key, value)
|
|
Karsten Hopp |
b3807e |
dd = DupDict()
|
|
Karsten Hopp |
b3807e |
dd['a'] = 'b'
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ class DupList(vim.List):
|
|
Karsten Hopp |
b3807e |
+ def __getitem__(self, idx):
|
|
Karsten Hopp |
b3807e |
+ return [super(DupList, self).__getitem__(idx)] * 2
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ dl = DupList()
|
|
Karsten Hopp |
b3807e |
+ dl2 = DupList(iter('abc'))
|
|
Karsten Hopp |
b3807e |
+ dl.extend(dl2[0])
|
|
Karsten Hopp |
b3807e |
EOF
|
|
Karsten Hopp |
b3807e |
:$put =string(sort(keys(pyeval('dd'))))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(pyeval('dl'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(pyeval('dl2'))
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
:" Test exceptions
|
|
Karsten Hopp |
b3807e |
:fun Exe(e)
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/testdir/test86.ok 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/testdir/test86.ok 2013-05-30 13:03:54.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 412,417 ****
|
|
Karsten Hopp |
b3807e |
--- 412,419 ----
|
|
Karsten Hopp |
b3807e |
{}
|
|
Karsten Hopp |
b3807e |
{'a': 1}
|
|
Karsten Hopp |
b3807e |
{'a': 1}
|
|
Karsten Hopp |
b3807e |
+ []
|
|
Karsten Hopp |
b3807e |
+ ['a', 'b', 'c']
|
|
Karsten Hopp |
b3807e |
'
|
|
Karsten Hopp |
b3807e |
abcdef
|
|
Karsten Hopp |
b3807e |
line :
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 420,425 ****
|
|
Karsten Hopp |
b3807e |
--- 422,429 ----
|
|
Karsten Hopp |
b3807e |
line :
|
|
Karsten Hopp |
b3807e |
abc'
|
|
Karsten Hopp |
b3807e |
['a', 'dup_a']
|
|
Karsten Hopp |
b3807e |
+ ['a', 'a']
|
|
Karsten Hopp |
b3807e |
+ ['a', 'b', 'c']
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('abc',))
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('def',))
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('ghi',))
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/testdir/test87.in 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/testdir/test87.in 2013-05-30 13:03:54.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 692,701 ****
|
|
Karsten Hopp |
b3807e |
del o
|
|
Karsten Hopp |
b3807e |
EOF
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
! :" Test vim.Dictionary.__new__
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary({})'))
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary(a=1)'))
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary(((''a'', 1),))'))
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
:" Test stdout/stderr
|
|
Karsten Hopp |
b3807e |
:redir => messages
|
|
Karsten Hopp |
b3807e |
--- 692,703 ----
|
|
Karsten Hopp |
b3807e |
del o
|
|
Karsten Hopp |
b3807e |
EOF
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
! :" Test vim.*.__new__
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary({})'))
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary(a=1)'))
|
|
Karsten Hopp |
b3807e |
:$put =string(py3eval('vim.Dictionary(((''a'', 1),))'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(py3eval('vim.List()'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(py3eval('vim.List(iter(''abc''))'))
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
:" Test stdout/stderr
|
|
Karsten Hopp |
b3807e |
:redir => messages
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 713,720 ****
|
|
Karsten Hopp |
b3807e |
--- 715,732 ----
|
|
Karsten Hopp |
b3807e |
super(DupDict, self).__setitem__('dup_' + key, value)
|
|
Karsten Hopp |
b3807e |
dd = DupDict()
|
|
Karsten Hopp |
b3807e |
dd['a'] = 'b'
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ class DupList(vim.List):
|
|
Karsten Hopp |
b3807e |
+ def __getitem__(self, idx):
|
|
Karsten Hopp |
b3807e |
+ return [super(DupList, self).__getitem__(idx)] * 2
|
|
Karsten Hopp |
b3807e |
+
|
|
Karsten Hopp |
b3807e |
+ dl = DupList()
|
|
Karsten Hopp |
b3807e |
+ dl2 = DupList(iter('abc'))
|
|
Karsten Hopp |
b3807e |
+ dl.extend(dl2[0])
|
|
Karsten Hopp |
b3807e |
EOF
|
|
Karsten Hopp |
b3807e |
:$put =string(sort(keys(py3eval('dd'))))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(py3eval('dl'))
|
|
Karsten Hopp |
b3807e |
+ :$put =string(py3eval('dl2'))
|
|
Karsten Hopp |
b3807e |
:"
|
|
Karsten Hopp |
b3807e |
:" Test exceptions
|
|
Karsten Hopp |
b3807e |
:fun Exe(e)
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/testdir/test87.ok 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/testdir/test87.ok 2013-05-30 13:03:54.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 401,406 ****
|
|
Karsten Hopp |
b3807e |
--- 401,408 ----
|
|
Karsten Hopp |
b3807e |
{}
|
|
Karsten Hopp |
b3807e |
{'a': 1}
|
|
Karsten Hopp |
b3807e |
{'a': 1}
|
|
Karsten Hopp |
b3807e |
+ []
|
|
Karsten Hopp |
b3807e |
+ ['a', 'b', 'c']
|
|
Karsten Hopp |
b3807e |
'
|
|
Karsten Hopp |
b3807e |
abcdef
|
|
Karsten Hopp |
b3807e |
line :
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 409,414 ****
|
|
Karsten Hopp |
b3807e |
--- 411,418 ----
|
|
Karsten Hopp |
b3807e |
line :
|
|
Karsten Hopp |
b3807e |
abc'
|
|
Karsten Hopp |
b3807e |
['a', 'dup_a']
|
|
Karsten Hopp |
b3807e |
+ ['a', 'a']
|
|
Karsten Hopp |
b3807e |
+ ['a', 'b', 'c']
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('abc',))
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('def',))
|
|
Karsten Hopp |
b3807e |
(<class 'vim.error'>, error('ghi',))
|
|
Karsten Hopp |
b3807e |
*** ../vim-7.3.1061/src/version.c 2013-05-30 13:01:14.000000000 +0200
|
|
Karsten Hopp |
b3807e |
--- src/version.c 2013-05-30 13:02:28.000000000 +0200
|
|
Karsten Hopp |
b3807e |
***************
|
|
Karsten Hopp |
b3807e |
*** 730,731 ****
|
|
Karsten Hopp |
b3807e |
--- 730,733 ----
|
|
Karsten Hopp |
b3807e |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
b3807e |
+ /**/
|
|
Karsten Hopp |
b3807e |
+ 1062,
|
|
Karsten Hopp |
b3807e |
/**/
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
--
|
|
Karsten Hopp |
b3807e |
How To Keep A Healthy Level Of Insanity:
|
|
Karsten Hopp |
b3807e |
5. Put decaf in the coffee maker for 3 weeks. Once everyone has gotten
|
|
Karsten Hopp |
b3807e |
over their caffeine addictions, switch to espresso.
|
|
Karsten Hopp |
b3807e |
|
|
Karsten Hopp |
b3807e |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
b3807e |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
b3807e |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
b3807e |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|