Skip to content

Commit 33db28d

Browse files
authored
Merge pull request #3968 from TwoPair/list-remove
2 parents 42290b1 + a678004 commit 33db28d

File tree

5 files changed

+5
-137
lines changed

5 files changed

+5
-137
lines changed

Lib/test/list_tests.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ def test_pop(self):
304304
self.assertRaises(TypeError, a.pop, 42, 42)
305305
a = self.type2test([0, 10, 20, 30, 40])
306306

307-
# TODO: RUSTPYTHON
308-
@unittest.expectedFailure
309307
def test_remove(self):
310308
a = self.type2test([0, 0, 1])
311309
a.remove(1)
@@ -365,8 +363,6 @@ def __eq__(self, other):
365363
# verify that original order and values are retained.
366364
self.assertIs(x, y)
367365

368-
# TODO: RUSTPYTHON
369-
@unittest.expectedFailure
370366
def test_index(self):
371367
super().test_index()
372368
a = self.type2test([-2, -1, 0, 0, 1, 2])

Lib/test/test_deque.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -929,21 +929,6 @@ def test_free_after_iterating(self):
929929
# For now, bypass tests that require slicing
930930
self.skipTest("Exhausted deque iterator doesn't free a deque")
931931

932-
# TODO: RUSTPYTHON
933-
@unittest.expectedFailure
934-
def test_contains_fake(self): # XXX: RUSTPYTHON; the method also need to be removed when done
935-
super().test_contains_fake()
936-
937-
# TODO: RUSTPYTHON
938-
@unittest.expectedFailure
939-
def test_count(self): # XXX: RUSTPYTHON; the method also need to be removed when done
940-
super().test_count()
941-
942-
# TODO: RUSTPYTHON
943-
@unittest.expectedFailure
944-
def test_index(self): # XXX: RUSTPYTHON; the method also need to be removed when done
945-
super().test_index()
946-
947932
#==============================================================================
948933

949934
libreftest = """

Lib/test/test_list.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,5 @@ def __eq__(self, other):
231231
lst = [X(), X()]
232232
X() in lst
233233

234-
# TODO: RUSTPYTHON
235-
@unittest.expectedFailure
236-
def test_count(self): # XXX: RUSTPYTHON; the method also need to be removed when done
237-
super().test_count()
238-
239-
# TODO: RUSTPYTHON
240-
@unittest.expectedFailure
241-
def test_contains_fake(self): # XXX: RUSTPYTHON; the method also need to be removed when done
242-
super().test_contains_fake()
243-
244234
if __name__ == "__main__":
245235
unittest.main()

Lib/test/test_userlist.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
class UserListTest(list_tests.CommonTest):
88
type2test = UserList
99

10-
# TODO: RUSTPYTHON
11-
@unittest.expectedFailure
12-
def test_contains_fake(self): # XXX: RUSTPYTHON; the method also need to be removed when done
13-
super().test_contains_fake()
14-
15-
# TODO: RUSTPYTHON
16-
@unittest.expectedFailure
17-
def test_count(self): # XXX: RUSTPYTHON; the method also need to be removed when done
18-
super().test_count()
19-
2010
import sys
2111
@unittest.skipIf(sys.platform == "win32", "TODO: RUSTPYTHON, unexpectedly panics somewhere")
2212
def test_repr_deep(self): # XXX: RUSTPYTHON; remove this method when fixed

vm/src/sequence.rs

Lines changed: 5 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
use crate::{
2-
builtins::PyIntRef,
3-
function::{Either, OptionalArg, PyComparisonValue},
4-
sliceable::SequenceIndexOp,
5-
types::{richcompare_wrapper, PyComparisonOp, RichCompareFunc},
6-
vm::VirtualMachine,
7-
AsObject, PyObject, PyObjectRef, PyResult,
2+
builtins::PyIntRef, function::OptionalArg, sliceable::SequenceIndexOp, types::PyComparisonOp,
3+
vm::VirtualMachine, AsObject, PyObject, PyObjectRef, PyResult,
84
};
95
use optional::Optioned;
106
use std::ops::Range;
@@ -50,11 +46,6 @@ pub trait MutObjectSequenceOp<'a> {
5046
where
5147
F: FnMut(),
5248
{
53-
let needle_cls = needle.class();
54-
let needle_cmp = needle_cls
55-
.mro_find_map(|cls| cls.slots.richcompare.load())
56-
.unwrap();
57-
5849
let mut borrower = None;
5950
let mut i = range.start;
6051

@@ -81,94 +72,10 @@ pub trait MutObjectSequenceOp<'a> {
8172
}
8273
borrower = Some(guard);
8374
} else {
84-
let elem_cls = elem.class();
85-
let reverse_first =
86-
!elem_cls.is(&needle_cls) && elem_cls.fast_issubclass(&needle_cls);
87-
88-
let eq = if reverse_first {
89-
let elem_cmp = elem_cls
90-
.mro_find_map(|cls| cls.slots.richcompare.load())
91-
.unwrap();
92-
drop(elem_cls);
93-
94-
fn cmp(
95-
elem: &PyObject,
96-
needle: &PyObject,
97-
elem_cmp: RichCompareFunc,
98-
needle_cmp: RichCompareFunc,
99-
vm: &VirtualMachine,
100-
) -> PyResult<bool> {
101-
match elem_cmp(elem, needle, PyComparisonOp::Eq, vm)? {
102-
Either::B(PyComparisonValue::Implemented(value)) => Ok(value),
103-
Either::A(obj) if !obj.is(&vm.ctx.not_implemented) => {
104-
obj.try_to_bool(vm)
105-
}
106-
_ => match needle_cmp(needle, elem, PyComparisonOp::Eq, vm)? {
107-
Either::B(PyComparisonValue::Implemented(value)) => Ok(value),
108-
Either::A(obj) if !obj.is(&vm.ctx.not_implemented) => {
109-
obj.try_to_bool(vm)
110-
}
111-
_ => Ok(false),
112-
},
113-
}
114-
}
115-
116-
if elem_cmp as usize == richcompare_wrapper as usize {
117-
let elem = elem.clone();
118-
drop(guard);
119-
cmp(&elem, needle, elem_cmp, needle_cmp, vm)?
120-
} else {
121-
let eq = cmp(elem, needle, elem_cmp, needle_cmp, vm)?;
122-
borrower = Some(guard);
123-
eq
124-
}
125-
} else {
126-
match needle_cmp(needle, elem, PyComparisonOp::Eq, vm)? {
127-
Either::B(PyComparisonValue::Implemented(value)) => {
128-
drop(elem_cls);
129-
borrower = Some(guard);
130-
value
131-
}
132-
Either::A(obj) if !obj.is(&vm.ctx.not_implemented) => {
133-
drop(elem_cls);
134-
borrower = Some(guard);
135-
obj.try_to_bool(vm)?
136-
}
137-
_ => {
138-
let elem_cmp = elem_cls
139-
.mro_find_map(|cls| cls.slots.richcompare.load())
140-
.unwrap();
141-
drop(elem_cls);
142-
143-
fn cmp(
144-
elem: &PyObject,
145-
needle: &PyObject,
146-
elem_cmp: RichCompareFunc,
147-
vm: &VirtualMachine,
148-
) -> PyResult<bool> {
149-
match elem_cmp(elem, needle, PyComparisonOp::Eq, vm)? {
150-
Either::B(PyComparisonValue::Implemented(value)) => Ok(value),
151-
Either::A(obj) if !obj.is(&vm.ctx.not_implemented) => {
152-
obj.try_to_bool(vm)
153-
}
154-
_ => Ok(false),
155-
}
156-
}
157-
158-
if elem_cmp as usize == richcompare_wrapper as usize {
159-
let elem = elem.clone();
160-
drop(guard);
161-
cmp(&elem, needle, elem_cmp, vm)?
162-
} else {
163-
let eq = cmp(elem, needle, elem_cmp, vm)?;
164-
borrower = Some(guard);
165-
eq
166-
}
167-
}
168-
}
169-
};
75+
let elem = elem.clone();
76+
drop(guard);
17077

171-
if eq {
78+
if elem.rich_compare_bool(needle, PyComparisonOp::Eq, vm)? {
17279
f();
17380
if SHORT {
17481
break Optioned::<usize>::some(i);

0 commit comments

Comments
 (0)