From e6d638d43fae2f23da60325510aa2a1ea4073bcb Mon Sep 17 00:00:00 2001 From: ZapAnton Date: Fri, 8 Feb 2019 18:56:34 +0300 Subject: [PATCH] iter type: Added __doc__ --- vm/src/obj/objiter.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vm/src/obj/objiter.rs b/vm/src/obj/objiter.rs index 7d4507212..a14a4d51e 100644 --- a/vm/src/obj/objiter.rs +++ b/vm/src/obj/objiter.rs @@ -161,6 +161,13 @@ fn iter_next(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { pub fn init(context: &PyContext) { let iter_type = &context.iter_type; + + let iter_doc = "iter(iterable) -> iterator\n\ + iter(callable, sentinel) -> iterator\n\n\ + Get an iterator from an object. In the first form, the argument must\n\ + supply its own iterator, or be a sequence.\n\ + In the second form, the callable is called until it returns the sentinel."; + context.set_attr( &iter_type, "__contains__", @@ -169,4 +176,5 @@ pub fn init(context: &PyContext) { context.set_attr(&iter_type, "__iter__", context.new_rustfunc(iter_iter)); context.set_attr(&iter_type, "__new__", context.new_rustfunc(iter_new)); context.set_attr(&iter_type, "__next__", context.new_rustfunc(iter_next)); + context.set_attr(&iter_type, "__doc__", context.new_str(iter_doc.to_string())); }