File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -311,8 +311,6 @@ def __getitem__(self, key):
311
311
return str (key ) + '!!!'
312
312
self .assertEqual (next (iter (T ((1 ,2 )))), 1 )
313
313
314
- # TODO: RUSTPYTHON
315
- @unittest .expectedFailure
316
314
def test_repeat (self ):
317
315
for m in range (4 ):
318
316
s = tuple (range (m ))
Original file line number Diff line number Diff line change @@ -169,11 +169,17 @@ impl PyTuple {
169
169
170
170
#[ pymethod( name = "__mul__" ) ]
171
171
#[ pymethod( name = "__rmul__" ) ]
172
- fn mul ( & self , counter : isize , vm : & VirtualMachine ) -> PyRef < Self > {
173
- if self . elements . is_empty ( ) || counter == 0 {
172
+ fn mul ( zelf : PyRef < Self > , counter : isize , vm : & VirtualMachine ) -> PyRef < Self > {
173
+ if zelf . elements . is_empty ( ) || counter == 0 {
174
174
vm. ctx . empty_tuple . clone ( )
175
+ } else if counter == 1 && zelf. clone_class ( ) . is ( PyTuple :: class ( vm) ) {
176
+ // Special case: when some `tuple` is multiplied by `1`,
177
+ // nothing really happens, we need to return an object itself
178
+ // with the same `id()` to be compatible with CPython.
179
+ // This only works for `tuple` itself, not its subclasses.
180
+ zelf
175
181
} else {
176
- let elements = sequence:: seq_mul ( & self . elements , counter)
182
+ let elements = sequence:: seq_mul ( & zelf . elements , counter)
177
183
. cloned ( )
178
184
. collect :: < Vec < _ > > ( )
179
185
. into_boxed_slice ( ) ;
You can’t perform that action at this time.
0 commit comments