From 4f87f875fce134fd435829fa0b46e54ef4ff15a7 Mon Sep 17 00:00:00 2001 From: Alexander Scharinger Date: Thu, 26 May 2022 00:07:17 +0200 Subject: [PATCH] Add filterfalse.__reduce__ --- Lib/test/test_itertools.py | 2 -- vm/src/stdlib/itertools.rs | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 7fa961f8557..23ede28c8eb 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -883,8 +883,6 @@ def test_filter(self): c = filter(isEven, range(6)) self.pickletest(proto, c) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_filterfalse(self): self.assertEqual(list(filterfalse(isEven, range(6))), [1,3,5]) self.assertEqual(list(filterfalse(None, [0,1,0,2,0])), [0,0,0]) diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index cad3dca66e2..a780e23923b 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -875,7 +875,15 @@ mod decl { } #[pyimpl(with(IterNext, Constructor))] - impl PyItertoolsFilterFalse {} + impl PyItertoolsFilterFalse { + #[pymethod(magic)] + fn reduce(zelf: PyRef) -> (PyTypeRef, (PyObjectRef, PyIter)) { + ( + zelf.class().clone(), + (zelf.predicate.clone(), zelf.iterable.clone()), + ) + } + } impl IterNextIterable for PyItertoolsFilterFalse {} impl IterNext for PyItertoolsFilterFalse { fn next(zelf: &Py, vm: &VirtualMachine) -> PyResult {