diff --git a/vm/src/builtins/coroutine.rs b/vm/src/builtins/coroutine.rs index 776692454..fe99d7a86 100644 --- a/vm/src/builtins/coroutine.rs +++ b/vm/src/builtins/coroutine.rs @@ -122,7 +122,7 @@ impl PyValue for PyCoroutineWrapper { } } -#[pyimpl] +#[pyimpl(with(PyIter))] impl PyCoroutineWrapper { #[pymethod] fn send(&self, val: PyObjectRef, vm: &VirtualMachine) -> PyResult { @@ -141,6 +141,12 @@ impl PyCoroutineWrapper { } } +impl PyIter for PyCoroutineWrapper { + fn next(zelf: &PyRef, vm: &VirtualMachine) -> PyResult { + zelf.send(vm.ctx.none(), vm) + } +} + pub fn init(ctx: &PyContext) { PyCoroutine::extend_class(ctx, &ctx.types.coroutine_type); PyCoroutineWrapper::extend_class(ctx, &ctx.types.coroutine_wrapper_type);