Skip to content

Fix bytecode::CallType::Ex to raise non-str type error #1726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ class N(type, metaclass=M):

class SimpleNamespaceTests(unittest.TestCase):

@unittest.skip("TODO: RUSTPYTHON")
def test_constructor(self):
ns1 = types.SimpleNamespace()
ns2 = types.SimpleNamespace(x=1, y=2)
Expand Down
13 changes: 9 additions & 4 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,15 @@ impl Frame {
let kwargs = if *has_kwargs {
let kw_dict: PyDictRef =
self.pop_value().downcast().expect("Kwargs must be a dict.");
kw_dict
.into_iter()
.map(|elem| (objstr::clone_value(&elem.0), elem.1))
.collect()
let mut kwargs = IndexMap::new();
for (key, value) in kw_dict.into_iter() {
if let Some(key) = key.payload_if_subclass::<objstr::PyString>(vm) {
kwargs.insert(key.as_str().to_owned(), value);
} else {
return Err(vm.new_type_error("keywords must be strings".to_owned()));
}
}
kwargs
} else {
IndexMap::new()
};
Expand Down