diff options
author | Raymond Hettinger <python@rcn.com> | 2017-02-06 07:15:57 -0800 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2017-02-06 07:15:57 -0800 |
commit | 826745ba953b4ef23462fb0bc2d7b3db23b51d89 (patch) | |
tree | 7789cc87df07c2786c40e6888cbb532a94ce6334 /Modules/_collectionsmodule.c | |
parent | 95b272b4e0d5438a12702e51e05d03f5a5a8e505 (diff) | |
parent | 515f1cf20f4e9656b1bcda236bad8ed0e33770f0 (diff) | |
download | cpython-826745ba953b4ef23462fb0bc2d7b3db23b51d89.tar.gz |
merge
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r-- | Modules/_collectionsmodule.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index e6111c64e7..8615bf1d39 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -538,7 +538,8 @@ deque_copy(PyObject *deque) return NULL; } if (old_deque->maxlen < 0) - return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL); + return PyObject_CallFunctionObjArgs((PyObject *)(Py_TYPE(deque)), + deque, NULL); else return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, old_deque->maxlen, NULL); @@ -907,12 +908,18 @@ done: } static PyObject * -deque_rotate(dequeobject *deque, PyObject *args) +deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs, + PyObject *kwnames) { Py_ssize_t n=1; - if (!PyArg_ParseTuple(args, "|n:rotate", &n)) + if (!_PyArg_NoStackKeywords("rotate", kwnames)) { return NULL; + } + if (!_PyArg_ParseStack(args, nargs, "|n:rotate", &n)) { + return NULL; + } + if (!_deque_rotate(deque, n)) Py_RETURN_NONE; return NULL; @@ -1041,7 +1048,8 @@ deque_len(dequeobject *deque) } static PyObject * -deque_index(dequeobject *deque, PyObject *args) +deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs, + PyObject *kwnames) { Py_ssize_t i, n, start=0, stop=Py_SIZE(deque); PyObject *v, *item; @@ -1050,10 +1058,15 @@ deque_index(dequeobject *deque, PyObject *args) size_t start_state = deque->state; int cmp; - if (!PyArg_ParseTuple(args, "O|O&O&:index", &v, - _PyEval_SliceIndex, &start, - _PyEval_SliceIndex, &stop)) + if (!_PyArg_NoStackKeywords("index", kwnames)) { + return NULL; + } + if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", &v, + _PyEval_SliceIndex, &start, + _PyEval_SliceIndex, &stop)) { return NULL; + } + if (start < 0) { start += Py_SIZE(deque); if (start < 0) @@ -1116,15 +1129,21 @@ PyDoc_STRVAR(index_doc, */ static PyObject * -deque_insert(dequeobject *deque, PyObject *args) +deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs, + PyObject *kwnames) { Py_ssize_t index; Py_ssize_t n = Py_SIZE(deque); PyObject *value; PyObject *rv; - if (!PyArg_ParseTuple(args, "nO:insert", &index, &value)) + if (!_PyArg_NoStackKeywords("insert", kwnames)) { + return NULL; + } + if (!_PyArg_ParseStack(args, nargs, "nO:insert", &index, &value)) { return NULL; + } + if (deque->maxlen == Py_SIZE(deque)) { PyErr_SetString(PyExc_IndexError, "deque already at its maximum size"); return NULL; @@ -1594,9 +1613,9 @@ static PyMethodDef deque_methods[] = { {"extendleft", (PyCFunction)deque_extendleft, METH_O, extendleft_doc}, {"index", (PyCFunction)deque_index, - METH_VARARGS, index_doc}, + METH_FASTCALL, index_doc}, {"insert", (PyCFunction)deque_insert, - METH_VARARGS, insert_doc}, + METH_FASTCALL, insert_doc}, {"pop", (PyCFunction)deque_pop, METH_NOARGS, pop_doc}, {"popleft", (PyCFunction)deque_popleft, @@ -1610,7 +1629,7 @@ static PyMethodDef deque_methods[] = { {"reverse", (PyCFunction)deque_reverse, METH_NOARGS, reverse_doc}, {"rotate", (PyCFunction)deque_rotate, - METH_VARARGS, rotate_doc}, + METH_FASTCALL, rotate_doc}, {"__sizeof__", (PyCFunction)deque_sizeof, METH_NOARGS, sizeof_doc}, {NULL, NULL} /* sentinel */ |