Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Lib/test/test_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,6 @@ async def consume():
self.loop.run_until_complete(consume())
self.assertEqual(results, [1, 2])

# TODO: RUSTPYTHON, NameError: name 'aiter' is not defined
@unittest.expectedFailure
def test_aiter_idempotent(self):
async def gen():
yield 1
Expand Down Expand Up @@ -766,8 +764,6 @@ def run_test(test):
run_test(test5)
run_test(test6)

# TODO: RUSTPYTHON, NameError: name 'aiter' is not defined
@unittest.expectedFailure
def test_aiter_bad_args(self):
async def gen():
yield 1
Expand Down
10 changes: 10 additions & 0 deletions vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod builtins {
use crate::compile;
use crate::{
builtins::{
asyncgenerator::PyAsyncGen,
enumerate::PyReverseSequenceIterator,
function::{PyCellRef, PyFunctionRef},
int::PyIntRef,
Expand Down Expand Up @@ -426,6 +427,15 @@ mod builtins {
}
}

#[pyfunction]
fn aiter(iter_target: PyObjectRef, vm: &VirtualMachine) -> PyResult {
if iter_target.payload_is::<PyAsyncGen>() {
vm.call_special_method(iter_target, "__aiter__", ())
} else {
Err(vm.new_type_error("wrong argument type".to_owned()))
}
}

#[pyfunction]
fn len(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
obj.length(vm)
Expand Down