Skip to content

Commit d08b04e

Browse files
committed
Implement minimal builtins.anext()
issue : #3609 Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
1 parent 9825d8a commit d08b04e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vm/src/stdlib/builtins.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,22 @@ mod builtins {
534534
iter_target.get_aiter(vm)
535535
}
536536

537+
#[pyfunction]
538+
fn anext(
539+
aiter: PyObjectRef,
540+
default_value: OptionalArg<PyObjectRef>,
541+
vm: &VirtualMachine,
542+
) -> PyResult {
543+
let awaitable = vm.call_method(&aiter, "__anext__", ())?;
544+
545+
if default_value.is_missing() {
546+
Ok(awaitable)
547+
} else {
548+
// TODO: Implement CPython like PyAnextAwaitable to properly handle the default value.
549+
Ok(awaitable)
550+
}
551+
}
552+
537553
#[pyfunction]
538554
fn len(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
539555
obj.length(vm)

0 commit comments

Comments
 (0)