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