[Python-checkins] cpython (merge 3.5 -> default): merge

raymond.hettinger python-checkins at python.org
Wed Aug 26 17:10:46 CEST 2015


https://hg.python.org/cpython/rev/b66a8240925a
changeset:   97513:b66a8240925a
parent:      97511:2e9cf58c891d
parent:      97512:ae8ec66adc7f
user:        Raymond Hettinger <python at rcn.com>
date:        Wed Aug 26 08:09:50 2015 -0700
summary:
  merge

files:
  Lib/test/test_deque.py       |  5 +++++
  Misc/NEWS                    |  3 +++
  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
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -83,6 +83,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 --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -924,6 +924,8 @@
         if (stop < 0)
             stop = 0;
     }
+    if (stop > Py_SIZE(deque))
+        stop = Py_SIZE(deque);
 
     for (i=0 ; i<stop ; i++) {
         if (i >= start) {

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list