diff options
author | Raymond Hettinger <python@rcn.com> | 2015-08-26 15:09:50 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-08-26 15:09:50 (GMT) |
commit | 7a1a0bbbf160e62f97d68d5743469ed56e3c1706 (patch) | |
tree | 0f090e62e91f9e158d4a9e370d4e25790fb5591a | |
parent | 69de2a576cde2d1cfeac67472ad9d22aa1e87a4b (diff) | |
parent | 87674ec7d51eb99586231fbd6469b10d1f4fa111 (diff) | |
download | cpython-7a1a0bbbf160e62f97d68d5743469ed56e3c1706.zip cpython-7a1a0bbbf160e62f97d68d5743469ed56e3c1706.tar.gz cpython-7a1a0bbbf160e62f97d68d5743469ed56e3c1706.tar.bz2 |
merge
-rw-r--r-- | Lib/test/test_deque.py | 5 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_collectionsmodule.c | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index b858509..8718716 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -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' @@ -83,6 +83,9 @@ Library 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 --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 35034a5..adf1fb6 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -924,6 +924,8 @@ deque_index(dequeobject *deque, PyObject *args) if (stop < 0) stop = 0; } + if (stop > Py_SIZE(deque)) + stop = Py_SIZE(deque); for (i=0 ; i<stop ; i++) { if (i >= start) { |