mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Issue #26194: Fix undefined behavior for deque.insert() when len(d) == maxlen
This commit is contained in:
parent
d4e51f45a9
commit
3743432302
4 changed files with 28 additions and 0 deletions
|
@ -304,6 +304,20 @@ class TestBasic(unittest.TestCase):
|
|||
s.insert(i, 'Z')
|
||||
self.assertEqual(list(d), s)
|
||||
|
||||
def test_index_bug_26194(self):
|
||||
data = 'ABC'
|
||||
for i in range(len(data) + 1):
|
||||
d = deque(data, len(data))
|
||||
d.insert(i, None)
|
||||
s = list(data)
|
||||
s.insert(i, None)
|
||||
s.pop()
|
||||
self.assertEqual(list(d), s)
|
||||
if i < len(data):
|
||||
self.assertIsNone(d[i])
|
||||
else:
|
||||
self.assertTrue(None not in d)
|
||||
|
||||
def test_imul(self):
|
||||
for n in (-10, -1, 0, 1, 2, 10, 1000):
|
||||
d = deque()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue