Skip to content

Commit e843149

Browse files
Fix map no iterables (#8478)
* map: raise TypeError when called with no iterables Assisted-by: Claude Code:claude-fable-5 * add test for map with no iterables Assisted-by: Claude Code:claude-fable-5 * removed expectedFailures * removed test for map constructed with no iterables - covered by existing in test_itertools
1 parent 05a9873 commit e843149

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/test/test_itertools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,6 @@ def test_repeat_with_negative_times(self):
11361136
self.assertEqual(repr(repeat('a', times=-1)), "repeat('a', 0)")
11371137
self.assertEqual(repr(repeat('a', times=-2)), "repeat('a', 0)")
11381138

1139-
@unittest.expectedFailure # TODO: RUSTPYTHON
11401139
def test_map(self):
11411140
self.assertEqual(list(map(operator.pow, range(3), range(1,7))),
11421141
[0**1, 1**2, 2**3])

crates/vm/src/builtins/map.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ impl Constructor for PyMap {
3737
fn py_new(
3838
_cls: &Py<PyType>,
3939
(mapper, iterators, args): Self::Args,
40-
_vm: &VirtualMachine,
40+
vm: &VirtualMachine,
4141
) -> PyResult<Self> {
4242
let iterators = iterators.into_vec();
43+
if iterators.is_empty() {
44+
return Err(vm.new_type_error("map() must have at least two arguments."));
45+
}
4346
let strict = Radium::new(args.strict.unwrap_or(false));
4447
Ok(Self {
4548
mapper,

0 commit comments

Comments
 (0)