Skip to content

Commit 2e792e6

Browse files
committed
Add test case in builtin_list.py
1 parent 62d071f commit 2e792e6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extra_tests/snippets/builtin_list.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,4 +655,17 @@ def __eq__(self, other):
655655
l = [1, 2, 3, m, 4]
656656
m.list = l
657657
l.remove(4)
658-
assert_raises(ValueError, lambda: l.index(4)) # element 4 must not be in the list
658+
assert_raises(ValueError, lambda: l.index(4)) # element 4 must not be in the list
659+
660+
# Test no panic occured when list elements was deleted in __eq__
661+
class rewrite_list_eq(list):
662+
pass
663+
664+
class poc:
665+
def __eq__(self, other):
666+
list1.clear()
667+
return self
668+
669+
list1 = rewrite_list_eq([poc()])
670+
list1.remove(list1)
671+
assert list1 == []

0 commit comments

Comments
 (0)