From d7f35caed4a4a754f616f1c216223a3b7af1861f Mon Sep 17 00:00:00 2001 From: William Goode Date: Sun, 9 Aug 2026 22:03:58 -0400 Subject: [PATCH 1/4] map: raise TypeError when called with no iterables Assisted-by: Claude Code:claude-fable-5 --- crates/vm/src/builtins/map.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/vm/src/builtins/map.rs b/crates/vm/src/builtins/map.rs index 4dda9caf211..cb8db23e640 100644 --- a/crates/vm/src/builtins/map.rs +++ b/crates/vm/src/builtins/map.rs @@ -37,9 +37,12 @@ impl Constructor for PyMap { fn py_new( _cls: &Py, (mapper, iterators, args): Self::Args, - _vm: &VirtualMachine, + vm: &VirtualMachine, ) -> PyResult { let iterators = iterators.into_vec(); + if iterators.is_empty() { + return Err(vm.new_type_error("map() must have at least two arguments.")); + } let strict = Radium::new(args.strict.unwrap_or(false)); Ok(Self { mapper, From 6769e2ed17b1a7e0e0cb7d6af229856de29e7336 Mon Sep 17 00:00:00 2001 From: William Goode Date: Sun, 9 Aug 2026 22:04:07 -0400 Subject: [PATCH 2/4] add test for map with no iterables Assisted-by: Claude Code:claude-fable-5 --- extra_tests/snippets/builtin_map.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extra_tests/snippets/builtin_map.py b/extra_tests/snippets/builtin_map.py index 559d108e38b..e6e71a8124b 100644 --- a/extra_tests/snippets/builtin_map.py +++ b/extra_tests/snippets/builtin_map.py @@ -24,6 +24,13 @@ def __iter__(self): assert next(it) == 2 assert next(it) == 3 +# test for no iterables +try: + map(lambda: 1) + assert False, "TypeError expected at map construction" +except TypeError as e: + assert str(e) == "map() must have at least two arguments." + def mapping(x): if x == 0: From f041b36338ede14af86e32728c13480a3507e787 Mon Sep 17 00:00:00 2001 From: william-goode Date: Mon, 10 Aug 2026 16:20:47 -0400 Subject: [PATCH 3/4] removed expectedFailures --- Lib/test/test_itertools.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index e865c9bf059..585f6611ade 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1136,7 +1136,6 @@ def test_repeat_with_negative_times(self): self.assertEqual(repr(repeat('a', times=-1)), "repeat('a', 0)") self.assertEqual(repr(repeat('a', times=-2)), "repeat('a', 0)") - @unittest.expectedFailure # TODO: RUSTPYTHON def test_map(self): self.assertEqual(list(map(operator.pow, range(3), range(1,7))), [0**1, 1**2, 2**3]) From 9ceb0673c0ad1f8187184e1315ef3d64cca3dd3a Mon Sep 17 00:00:00 2001 From: william-goode Date: Mon, 10 Aug 2026 18:06:01 -0400 Subject: [PATCH 4/4] removed test for map constructed with no iterables - covered by existing in test_itertools --- extra_tests/snippets/builtin_map.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/extra_tests/snippets/builtin_map.py b/extra_tests/snippets/builtin_map.py index e6e71a8124b..559d108e38b 100644 --- a/extra_tests/snippets/builtin_map.py +++ b/extra_tests/snippets/builtin_map.py @@ -24,13 +24,6 @@ def __iter__(self): assert next(it) == 2 assert next(it) == 3 -# test for no iterables -try: - map(lambda: 1) - assert False, "TypeError expected at map construction" -except TypeError as e: - assert str(e) == "map() must have at least two arguments." - def mapping(x): if x == 0: