mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-120384: Fix array-out-of-bounds crash in list_ass_subscript (#120442)
This commit is contained in:
parent
733dac01b0
commit
8334a1b55c
4 changed files with 58 additions and 12 deletions
|
|
@ -245,6 +245,20 @@ class ListTest(list_tests.CommonTest):
|
|||
with self.assertRaises(TypeError):
|
||||
a[0] < a
|
||||
|
||||
def test_list_index_modifing_operand(self):
|
||||
# See gh-120384
|
||||
class evil:
|
||||
def __init__(self, lst):
|
||||
self.lst = lst
|
||||
def __iter__(self):
|
||||
yield from self.lst
|
||||
self.lst.clear()
|
||||
|
||||
lst = list(range(5))
|
||||
operand = evil(lst)
|
||||
with self.assertRaises(ValueError):
|
||||
lst[::-1] = operand
|
||||
|
||||
@cpython_only
|
||||
def test_preallocation(self):
|
||||
iterable = [0] * 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue