diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 8f5b8f0e171..dfdf307798a 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -927,8 +927,6 @@ def badfunc(x): raise RuntimeError self.assertRaises(RuntimeError, list, map(badfunc, range(5))) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_map_pickle(self): for proto in range(pickle.HIGHEST_PROTOCOL + 1): m1 = map(map_char, "Is this the real life?") diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 39f0dd63686..28690b11ba6 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -100,8 +100,6 @@ def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes super().test_c_methods() # TODO: RUSTPYTHON, remove when this passes - # TODO: RUSTPYTHON, TypeError: cannot pickle 'map' object - @unittest.expectedFailure def test_compat_pickle(self): # TODO: RUSTPYTHON, remove when this passes super().test_compat_pickle() # TODO: RUSTPYTHON, remove when this passes @@ -211,8 +209,6 @@ def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes super().test_c_methods() # TODO: RUSTPYTHON, remove when this passes - # TODO: RUSTPYTHON, TypeError: cannot pickle 'map' object - @unittest.expectedFailure def test_compat_pickle(self): # TODO: RUSTPYTHON, remove when this passes super().test_compat_pickle() # TODO: RUSTPYTHON, remove when this passes diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py index ae4b7eb1785..3920261bd39 100644 --- a/Lib/test/test_pickletools.py +++ b/Lib/test/test_pickletools.py @@ -22,8 +22,6 @@ def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes super().test_c_methods() - # TODO: RUSTPYTHON, TypeError: cannot pickle 'map' object - @unittest.expectedFailure def test_compat_pickle(self): # TODO: RUSTPYTHON, remove when this passes super().test_compat_pickle() diff --git a/vm/src/builtins/map.rs b/vm/src/builtins/map.rs index 21769149d62..3e857273715 100644 --- a/vm/src/builtins/map.rs +++ b/vm/src/builtins/map.rs @@ -1,5 +1,6 @@ use super::PyTypeRef; use crate::{ + builtins::PyTupleRef, class::PyClassImpl, function::PosArgs, protocol::{PyIter, PyIterReturn}, @@ -45,6 +46,13 @@ impl PyMap { Ok(max) }) } + + #[pymethod(magic)] + fn reduce(&self, vm: &VirtualMachine) -> (PyTypeRef, PyTupleRef) { + let mut vec = vec![self.mapper.clone()]; + vec.extend(self.iterators.iter().map(|o| o.clone().into())); + (vm.ctx.types.map_type.clone(), vm.new_tuple(vec)) + } } impl IterNextIterable for PyMap {}