mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
merge
This commit is contained in:
commit
0ef0423cb2
3 changed files with 24 additions and 0 deletions
|
@ -1085,10 +1085,17 @@ deque_insert(dequeobject *deque, PyObject *args)
|
|||
Py_ssize_t index;
|
||||
Py_ssize_t n = Py_SIZE(deque);
|
||||
PyObject *value;
|
||||
PyObject *oldvalue;
|
||||
PyObject *rv;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "nO:insert", &index, &value))
|
||||
return NULL;
|
||||
if (deque->maxlen == Py_SIZE(deque)) {
|
||||
if (index >= deque->maxlen || Py_SIZE(deque) == 0)
|
||||
Py_RETURN_NONE;
|
||||
oldvalue = deque_pop(deque, NULL);
|
||||
Py_DECREF(oldvalue);
|
||||
}
|
||||
if (index >= n)
|
||||
return deque_append(deque, value);
|
||||
if (index <= -n || index == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue