Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Check for PyAsyncGen when calling aiter
  • Loading branch information
sum12 committed Apr 21, 2022
commit 5fdf62a6b9336309f6d0e8db2a1b521e0b65bd80
7 changes: 6 additions & 1 deletion 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 @@ -428,7 +429,11 @@ mod builtins {

#[pyfunction]
fn aiter(iter_target: PyObjectRef, vm: &VirtualMachine) -> PyResult {
vm.call_special_method(iter_target, "__aiter__", ())
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]
Expand Down