Merge pull request #1726 from youknowone/calltype-ex

Fix bytecode::CallType::Ex to raise non-str type error
This commit is contained in:
Jeong YunWon
2020-02-01 12:32:51 +09:00
committed by GitHub
2 changed files with 9 additions and 5 deletions

View File

@@ -1191,7 +1191,6 @@ class ClassCreationTests(unittest.TestCase):
class SimpleNamespaceTests(unittest.TestCase):
@unittest.skip("TODO: RUSTPYTHON")
def test_constructor(self):
ns1 = types.SimpleNamespace()
ns2 = types.SimpleNamespace(x=1, y=2)

View File

@@ -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()
};