@@ -22,6 +22,8 @@ def test_basic(self):
2222
2323 if sys .maxsize == 0x7fffffff :
2424 # This test can currently only work on 32-bit machines.
25+ # XXX If/when PySequence_Length() returns a ssize_t, it should be
26+ # XXX re-enabled.
2527 # Verify clearing of bug #556025.
2628 # This assumes that the max data size (sys.maxint) == max
2729 # address size this also assumes that the address size is at
@@ -97,15 +99,15 @@ def imul(a, b): a *= b
9799 self .assertRaises ((MemoryError , OverflowError ), imul , lst , n )
98100
99101 # TODO: RUSTPYTHON
100- @unittest .expectedFailure
102+ @unittest .skip ( "Crashes on windows debug build" )
101103 def test_list_resize_overflow (self ):
102104 # gh-97616: test new_allocated * sizeof(PyObject*) overflow
103105 # check in list_resize()
104106 lst = [0 ] * 65
105107 del lst [1 :]
106108 self .assertEqual (len (lst ), 1 )
107109
108- size = (( 2 ** ( tuple . __itemsize__ * 8 ) - 1 ) // 2 )
110+ size = sys . maxsize
109111 with self .assertRaises ((MemoryError , OverflowError )):
110112 lst * size
111113 with self .assertRaises ((MemoryError , OverflowError )):
@@ -117,7 +119,7 @@ def check(n):
117119 l = [0 ] * n
118120 s = repr (l )
119121 self .assertEqual (s ,
120- '[' + ', ' .join (['0' ] * n ) + ']' )
122+ '[' + ', ' .join (['0' ] * n ) + ']' )
121123 check (10 ) # check our checking code
122124 check (1000000 )
123125
@@ -206,6 +208,7 @@ class L(list): pass
206208 with self .assertRaises (TypeError ):
207209 (3 ,) + L ([1 ,2 ])
208210
211+ # TODO: RUSTPYTHON
209212 @unittest .skip ("TODO: RUSTPYTHON; hang" )
210213 def test_equal_operator_modifying_operand (self ):
211214 # test fix for seg fault reported in bpo-38588 part 2.
@@ -232,6 +235,33 @@ def __eq__(self, other):
232235 list4 = [1 ]
233236 self .assertFalse (list3 == list4 )
234237
238+ # TODO: RUSTPYTHON
239+ @unittest .skip ("TODO: RUSTPYTHON; hang" )
240+ def test_lt_operator_modifying_operand (self ):
241+ # See gh-120298
242+ class evil :
243+ def __lt__ (self , other ):
244+ other .clear ()
245+ return NotImplemented
246+
247+ a = [[evil ()]]
248+ with self .assertRaises (TypeError ):
249+ a [0 ] < a
250+
251+ def test_list_index_modifing_operand (self ):
252+ # See gh-120384
253+ class evil :
254+ def __init__ (self , lst ):
255+ self .lst = lst
256+ def __iter__ (self ):
257+ yield from self .lst
258+ self .lst .clear ()
259+
260+ lst = list (range (5 ))
261+ operand = evil (lst )
262+ with self .assertRaises (ValueError ):
263+ lst [::- 1 ] = operand
264+
235265 @cpython_only
236266 def test_preallocation (self ):
237267 iterable = [0 ] * 10
0 commit comments