changeset: 97638:9f8c59e61594 branch: 3.5 parent: 97583:e9df8543d7bc user: Brett Cannon date: Thu Sep 03 10:15:03 2015 -0700 files: Lib/test/test_deque.py Misc/NEWS Modules/_collectionsmodule.c description: Issue #24913: Fix overrun error in deque.index(). Reported by John Leitch and Bryce Darling, patch by Raymond Hettinger. diff -r e9df8543d7bc -r 9f8c59e61594 Lib/test/test_deque.py --- a/Lib/test/test_deque.py Tue Sep 01 16:10:49 2015 -0400 +++ b/Lib/test/test_deque.py Thu Sep 03 10:15:03 2015 -0700 @@ -289,6 +289,11 @@ 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' diff -r e9df8543d7bc -r 9f8c59e61594 Misc/NEWS --- a/Misc/NEWS Tue Sep 01 16:10:49 2015 -0400 +++ b/Misc/NEWS Thu Sep 03 10:15:03 2015 -0700 @@ -15,6 +15,9 @@ 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? =============================================== diff -r e9df8543d7bc -r 9f8c59e61594 Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Tue Sep 01 16:10:49 2015 -0400 +++ b/Modules/_collectionsmodule.c Thu Sep 03 10:15:03 2015 -0700 @@ -924,6 +924,8 @@ if (stop < 0) stop = 0; } + if (stop > Py_SIZE(deque)) + stop = Py_SIZE(deque); for (i=0 ; i= start) {