Issue #24913: Fix overrun error in deque.index().

Reported by John Leitch and Bryce Darling, patch by Raymond Hettinger.
This commit is contained in:
Brett Cannon 2015-09-03 10:15:03 -07:00
parent b3d531348c
commit df6b544ff6
3 changed files with 10 additions and 0 deletions

View file

@ -289,6 +289,11 @@ class TestBasic(unittest.TestCase):
else:
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):
# Test to make sure insert behaves like lists
elements = 'ABCDEFGHI'