Add an early-out for deque_clear()

This commit is contained in:
Raymond Hettinger 2015-09-29 22:45:05 -07:00
parent 17f9716676
commit 38031143fb
1 changed files with 3 additions and 0 deletions

View File

@ -595,6 +595,9 @@ deque_clear(dequeobject *deque)
Py_ssize_t n;
PyObject *item;
if (Py_SIZE(deque) == 0)
return;
/* During the process of clearing a deque, decrefs can cause the
deque to mutate. To avoid fatal confusion, we have to make the
deque empty before clearing the blocks and never refer to