changeset: 97512:ae8ec66adc7f branch: 3.5 parent: 97509:91376b651e53 user: Raymond Hettinger date: Wed Aug 26 08:08:38 2015 -0700 files: Lib/test/test_deque.py Misc/NEWS Modules/_collectionsmodule.c description: Issue #24913: Fix overrun error in deque.index(). diff -r 91376b651e53 -r ae8ec66adc7f Lib/test/test_deque.py --- a/Lib/test/test_deque.py Tue Aug 25 17:21:22 2015 -0700 +++ b/Lib/test/test_deque.py Wed Aug 26 08:08:38 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 91376b651e53 -r ae8ec66adc7f Misc/NEWS --- a/Misc/NEWS Tue Aug 25 17:21:22 2015 -0700 +++ b/Misc/NEWS Wed Aug 26 08:08:38 2015 -0700 @@ -18,6 +18,9 @@ header in part headers. Patch written by Peter Landry and reviewed by Pierre Quentel. +- Issue #24913: Fix overrun error in deque.index(). + Found by John Leitch and Bryce Darling. + - Issue #24774: Fix docstring in http.server.test. Patch from Chiu-Hsiang Hsu. - Issue #21159: Improve message in configparser.InterpolationMissingOptionError. diff -r 91376b651e53 -r ae8ec66adc7f Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Tue Aug 25 17:21:22 2015 -0700 +++ b/Modules/_collectionsmodule.c Wed Aug 26 08:08:38 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) {