tp_iternext for coroutine_wrapper

This commit is contained in:
Noah
2021-02-19 08:20:32 -06:00
parent fb2efa95f9
commit a46fb496aa

View File

@@ -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<Self>, 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);