0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.1096

Problem:    Python: popitem() was not defined in a standard way.
Solution:   Remove the argument from popitem(). (ZyX)
This commit is contained in:
Bram Moolenaar
2013-06-02 17:41:54 +02:00
parent 525666f282
commit de71b5658f
7 changed files with 44 additions and 31 deletions

View File

@@ -1061,17 +1061,6 @@ _DictionaryItem(DictionaryObject *self, PyObject *args, int flags)
dictitem_free(di);
}
if (flags & DICT_FLAG_RETURN_PAIR)
{
PyObject *tmp = r;
if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, tmp)))
{
Py_DECREF(tmp);
return NULL;
}
}
return r;
}
@@ -1457,15 +1446,38 @@ DictionaryPop(DictionaryObject *self, PyObject *args)
}
static PyObject *
DictionaryPopItem(DictionaryObject *self, PyObject *args)
DictionaryPopItem(DictionaryObject *self)
{
PyObject *keyObject;
hashitem_T *hi;
PyObject *r;
PyObject *valObject;
dictitem_T *di;
if (!PyArg_ParseTuple(args, "O", &keyObject))
if (self->dict->dv_hashtab.ht_used == 0)
{
PyErr_SetNone(PyExc_KeyError);
return NULL;
}
hi = self->dict->dv_hashtab.ht_array;
while (HASHITEM_EMPTY(hi))
++hi;
di = dict_lookup(hi);
if (!(valObject = ConvertToPyObject(&di->di_tv)))
return NULL;
return _DictionaryItem(self, keyObject,
DICT_FLAG_POP|DICT_FLAG_RETURN_PAIR);
if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, valObject)))
{
Py_DECREF(valObject);
return NULL;
}
hash_remove(&self->dict->dv_hashtab, hi);
dictitem_free(di);
return r;
}
static PyObject *
@@ -1505,7 +1517,7 @@ static struct PyMethodDef DictionaryMethods[] = {
{"update", (PyCFunction)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""},
{"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""},
{"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""},
{"popitem", (PyCFunction)DictionaryPopItem, METH_VARARGS, ""},
{"popitem", (PyCFunction)DictionaryPopItem, METH_NOARGS, ""},
{"has_key", (PyCFunction)DictionaryHasKey, METH_VARARGS, ""},
{"__dir__", (PyCFunction)DictionaryDir, METH_NOARGS, ""},
{ NULL, NULL, 0, NULL}