Issue #24913: Fix overrun error in deque.index().
This commit is contained in:
parent
9783e443bc
commit
87674ec7d5
|
@ -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'
|
||||
|
|
|
@ -18,6 +18,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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue