Skip to content

Commit 8f4367b

Browse files
committed
Fix: adjust error message for container/iterables
1 parent f576318 commit 8f4367b

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

Lib/test/test_contains.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def __getitem__(self, n):
1616
return [self.el][n]
1717

1818
class TestContains(unittest.TestCase):
19-
@unittest.expectedFailure # TODO: RUSTPYTHON; Wrong error message
2019
def test_common_tests(self):
2120
a = base_set(1)
2221
b = myset(1)

crates/stdlib/src/csv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ mod _csv {
10951095
}
10961096

10971097
let row = ArgIterable::try_from_object(vm, row.clone()).map_err(|_e| {
1098-
new_csv_error(vm, format!("\'{}\' object is not iterable", row.class()))
1098+
new_csv_error(vm, format!("argument of type \'{}\' is not a container or iterable", row.class()))
10991099
})?;
11001100
let mut first_flag = true;
11011101
for field in row.iter(vm)? {

crates/vm/src/function/protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ where
107107
let cls = obj.class();
108108
let iter_fn = cls.slots.iter.load();
109109
if iter_fn.is_none() && !cls.has_attr(identifier!(vm, __getitem__)) {
110-
return Err(vm.new_type_error(format!("'{}' object is not iterable", cls.name())));
110+
return Err(vm.new_type_error(format!("argument of type \'{}\' is not a container or iterable", cls.name())));
111111
}
112112
Ok(Self {
113113
iterable: obj,

crates/vm/src/protocol/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl TryFromObject for PyIter<PyObjectRef> {
140140
Ok(Self(seq_iter.into_pyobject(vm)))
141141
} else {
142142
Err(vm.new_type_error(format!(
143-
"'{}' object is not iterable",
143+
"argument of type \'{}\' is not a container or iterable",
144144
iter_target.class().name()
145145
)))
146146
}

0 commit comments

Comments
 (0)