objtype: Set __doc__ as None if not included

This set __doc__ as None if it is not included in attribute
while making new instance of type.
In cpython if there is no docstring in class definition,
__doc__ attribute will be None. So RustPython should follow it.

Partially solves #1523
This commit is contained in:
joshua1b
2019-10-20 15:54:33 +09:00
parent ff54fc88e8
commit 848727b64e

View File

@@ -321,7 +321,12 @@ fn type_new_slot(metatype: PyClassRef, args: PyFuncArgs, vm: &VirtualMachine) ->
bases
};
let attributes = dict.to_attributes();
let mut attributes = dict.to_attributes();
// insert __doc__ as None if it is not included in attributes
if !attributes.contains_key("__doc__") {
attributes.insert("__doc__".to_string(), vm.ctx.none());
}
let mut winner = metatype.clone();
for base in &bases {