Merge pull request #399 from ZapAnton/super_doc

super type: Added __doc__
This commit is contained in:
Windel Bouwman
2019-02-08 20:08:22 +01:00
committed by GitHub

View File

@@ -12,7 +12,27 @@ use super::objtype;
pub fn init(context: &PyContext) {
let super_type = &context.super_type;
let super_doc = "super() -> same as super(__class__, <first argument>)\n\
super(type) -> unbound super object\n\
super(type, obj) -> bound super object; requires isinstance(obj, type)\n\
super(type, type2) -> bound super object; requires issubclass(type2, type)\n\
Typical use to call a cooperative superclass method:\n\
class C(B):\n \
def meth(self, arg):\n \
super().meth(arg)\n\
This works for class methods too:\n\
class C(B):\n \
@classmethod\n \
def cmeth(cls, arg):\n \
super().cmeth(arg)\n";
context.set_attr(&super_type, "__init__", context.new_rustfunc(super_init));
context.set_attr(
&super_type,
"__doc__",
context.new_str(super_doc.to_string()),
);
}
fn super_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {