diff options
author | Raymond Hettinger <python@rcn.com> | 2013-02-02 19:24:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2013-02-02 19:24:43 (GMT) |
commit | 231ee4dc9da8d85aceb9ef18aa7197dd0023534e (patch) | |
tree | 6d90aad9521f967482496fe5f95b8aa0e8113758 /Modules/_collectionsmodule.c | |
parent | 21777acd684e9d74ad8847413ff2df0e418b07bd (diff) | |
download | cpython-231ee4dc9da8d85aceb9ef18aa7197dd0023534e.zip cpython-231ee4dc9da8d85aceb9ef18aa7197dd0023534e.tar.gz cpython-231ee4dc9da8d85aceb9ef18aa7197dd0023534e.tar.bz2 |
Issue 16398: Add assertions to show why memcmp is safe.
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r-- | Modules/_collectionsmodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index e0c6f0c..17b1ad6 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -425,8 +425,9 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) else if (n < -halflen) n += len; } - assert(deque->len > 1); + assert((n < len / 2) || (n > len / -2)); + deque->state++; for (i=0 ; i<n ; ) { if (deque->leftindex == 0) { @@ -446,6 +447,8 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) if (m > deque->leftindex) m = deque->leftindex; assert (m > 0); + assert (deque->leftblock != deque->rightblock || + deque->leftindex < deque->rightindex - m + 1); memcpy(&deque->leftblock->data[deque->leftindex - m], &deque->rightblock->data[deque->rightindex - m + 1], m * sizeof(PyObject *)); |