mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #24913: Fix overrun error in deque.index().
Reported by John Leitch and Bryce Darling, patch by Raymond Hettinger.
This commit is contained in:
parent
b3d531348c
commit
df6b544ff6
3 changed files with 10 additions and 0 deletions
|
@ -289,6 +289,11 @@ class TestBasic(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
self.assertEqual(d.index(element, start, stop), target)
|
self.assertEqual(d.index(element, start, stop), target)
|
||||||
|
|
||||||
|
def test_insert_bug_24913(self):
|
||||||
|
d = deque('A' * 3)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
i = d.index("Hello world", 0, 4)
|
||||||
|
|
||||||
def test_insert(self):
|
def test_insert(self):
|
||||||
# Test to make sure insert behaves like lists
|
# Test to make sure insert behaves like lists
|
||||||
elements = 'ABCDEFGHI'
|
elements = 'ABCDEFGHI'
|
||||||
|
|
|
@ -15,6 +15,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #24913: Fix overrun error in deque.index().
|
||||||
|
Found by John Leitch and Bryce Darling.
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 3.5.0 release candidate 2?
|
What's New in Python 3.5.0 release candidate 2?
|
||||||
===============================================
|
===============================================
|
||||||
|
|
|
@ -924,6 +924,8 @@ deque_index(dequeobject *deque, PyObject *args)
|
||||||
if (stop < 0)
|
if (stop < 0)
|
||||||
stop = 0;
|
stop = 0;
|
||||||
}
|
}
|
||||||
|
if (stop > Py_SIZE(deque))
|
||||||
|
stop = Py_SIZE(deque);
|
||||||
|
|
||||||
for (i=0 ; i<stop ; i++) {
|
for (i=0 ; i<stop ; i++) {
|
||||||
if (i >= start) {
|
if (i >= start) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue