@@ -21,7 +21,7 @@ def test_basic(self):
21
21
[1 , 3 , 5 , 7 , 9 ])
22
22
23
23
# XXX RUSTPYTHON TODO: catch ooms
24
- if sys .maxsize == 0x7fffffff and False :
24
+ if sys .maxsize == 0x7fffffff :
25
25
# This test can currently only work on 32-bit machines.
26
26
# XXX If/when PySequence_Length() returns a ssize_t, it should be
27
27
# XXX re-enabled.
@@ -47,6 +47,36 @@ def test_keyword_args(self):
47
47
with self .assertRaisesRegex (TypeError , 'keyword argument' ):
48
48
list (sequence = [])
49
49
50
+ # TODO: RUSTPYTHON
51
+ @unittest .expectedFailure
52
+ def test_keywords_in_subclass (self ):
53
+ class subclass (list ):
54
+ pass
55
+ u = subclass ([1 , 2 ])
56
+ self .assertIs (type (u ), subclass )
57
+ self .assertEqual (list (u ), [1 , 2 ])
58
+ with self .assertRaises (TypeError ):
59
+ subclass (sequence = ())
60
+
61
+ class subclass_with_init (list ):
62
+ def __init__ (self , seq , newarg = None ):
63
+ super ().__init__ (seq )
64
+ self .newarg = newarg
65
+ u = subclass_with_init ([1 , 2 ], newarg = 3 )
66
+ self .assertIs (type (u ), subclass_with_init )
67
+ self .assertEqual (list (u ), [1 , 2 ])
68
+ self .assertEqual (u .newarg , 3 )
69
+
70
+ class subclass_with_new (list ):
71
+ def __new__ (cls , seq , newarg = None ):
72
+ self = super ().__new__ (cls , seq )
73
+ self .newarg = newarg
74
+ return self
75
+ u = subclass_with_new ([1 , 2 ], newarg = 3 )
76
+ self .assertIs (type (u ), subclass_with_new )
77
+ self .assertEqual (list (u ), [1 , 2 ])
78
+ self .assertEqual (u .newarg , 3 )
79
+
50
80
def test_truth (self ):
51
81
super ().test_truth ()
52
82
self .assertTrue (not [])
@@ -69,6 +99,21 @@ def imul(a, b): a *= b
69
99
self .assertRaises ((MemoryError , OverflowError ), mul , lst , n )
70
100
self .assertRaises ((MemoryError , OverflowError ), imul , lst , n )
71
101
102
+ # TODO: RUSTPYTHON
103
+ @unittest .expectedFailure
104
+ def test_list_resize_overflow (self ):
105
+ # gh-97616: test new_allocated * sizeof(PyObject*) overflow
106
+ # check in list_resize()
107
+ lst = [0 ] * 65
108
+ del lst [1 :]
109
+ self .assertEqual (len (lst ), 1 )
110
+
111
+ size = ((2 ** (tuple .__itemsize__ * 8 ) - 1 ) // 2 )
112
+ with self .assertRaises ((MemoryError , OverflowError )):
113
+ lst * size
114
+ with self .assertRaises ((MemoryError , OverflowError )):
115
+ lst *= size
116
+
72
117
def test_repr_large (self ):
73
118
# Check the repr of large list objects
74
119
def check (n ):
@@ -230,5 +275,6 @@ def __eq__(self, other):
230
275
lst = [X (), X ()]
231
276
X () in lst
232
277
278
+
233
279
if __name__ == "__main__" :
234
280
unittest .main ()
0 commit comments