Skip to content

Commit bdc80dc

Browse files
committed
dict() now should work properly
e.g. ``` dict(a=2, b=3) == {"a": 2, "b": 3} ```
1 parent a796b13 commit bdc80dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vm/src/obj/objdict.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ pub fn content_contains_key_str(elements: &DictContentType, key: &str) -> bool {
113113

114114
// Python dict methods:
115115

116-
fn dict_new(_vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
117-
Ok(new(args.args[0].clone()))
116+
fn dict_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
117+
let dict = new(args.args[0].clone());
118+
for (needle, value) in args.kwargs {
119+
set_item(&dict, &vm.new_str(needle), &value);
120+
}
121+
Ok(dict)
118122
}
119123

120124
fn dict_len(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {

0 commit comments

Comments
 (0)