Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix: adjust error message for container/iterables
  • Loading branch information
feliwir committed Apr 8, 2026
commit c697f278d70137a0e914feba6419c3b792a67e08
1 change: 0 additions & 1 deletion Lib/test/test_contains.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __getitem__(self, n):
return [self.el][n]

class TestContains(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON; Wrong error message
def test_common_tests(self):
a = base_set(1)
b = myset(1)
Expand Down
8 changes: 7 additions & 1 deletion crates/stdlib/src/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,13 @@ mod _csv {
}

let row = ArgIterable::try_from_object(vm, row.clone()).map_err(|_e| {
new_csv_error(vm, format!("\'{}\' object is not iterable", row.class()))
new_csv_error(
vm,
format!(
"argument of type \'{}\' is not a container or iterable",
row.class()
),
)
})?;
let mut first_flag = true;
for field in row.iter(vm)? {
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/function/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ where
let cls = obj.class();
let iter_fn = cls.slots.iter.load();
if iter_fn.is_none() && !cls.has_attr(identifier!(vm, __getitem__)) {
return Err(vm.new_type_error(format!("'{}' object is not iterable", cls.name())));
return Err(vm.new_type_error(format!(
"argument of type \'{}\' is not a container or iterable",
cls.name()
)));
}
Ok(Self {
iterable: obj,
Expand Down
2 changes: 1 addition & 1 deletion crates/vm/src/protocol/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl TryFromObject for PyIter<PyObjectRef> {
Ok(Self(seq_iter.into_pyobject(vm)))
} else {
Err(vm.new_type_error(format!(
"'{}' object is not iterable",
"argument of type \'{}\' is not a container or iterable",
iter_target.class().name()
)))
}
Expand Down
Loading