Skip to content

Commit 7cdaba7

Browse files
authored
Merge pull request #1726 from youknowone/calltype-ex
Fix bytecode::CallType::Ex to raise non-str type error
2 parents 53e27eb + 2a47785 commit 7cdaba7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Lib/test/test_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,6 @@ class N(type, metaclass=M):
11911191

11921192
class SimpleNamespaceTests(unittest.TestCase):
11931193

1194-
@unittest.skip("TODO: RUSTPYTHON")
11951194
def test_constructor(self):
11961195
ns1 = types.SimpleNamespace()
11971196
ns2 = types.SimpleNamespace(x=1, y=2)

vm/src/frame.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,10 +937,15 @@ impl Frame {
937937
let kwargs = if *has_kwargs {
938938
let kw_dict: PyDictRef =
939939
self.pop_value().downcast().expect("Kwargs must be a dict.");
940-
kw_dict
941-
.into_iter()
942-
.map(|elem| (objstr::clone_value(&elem.0), elem.1))
943-
.collect()
940+
let mut kwargs = IndexMap::new();
941+
for (key, value) in kw_dict.into_iter() {
942+
if let Some(key) = key.payload_if_subclass::<objstr::PyString>(vm) {
943+
kwargs.insert(key.as_str().to_owned(), value);
944+
} else {
945+
return Err(vm.new_type_error("keywords must be strings".to_owned()));
946+
}
947+
}
948+
kwargs
944949
} else {
945950
IndexMap::new()
946951
};

0 commit comments

Comments
 (0)