Skip to content

Commit 5fdf62a

Browse files
committed
Check for PyAsyncGen when calling aiter
1 parent d74a1d5 commit 5fdf62a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vm/src/stdlib/builtins.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod builtins {
1212
use crate::compile;
1313
use crate::{
1414
builtins::{
15+
asyncgenerator::PyAsyncGen,
1516
enumerate::PyReverseSequenceIterator,
1617
function::{PyCellRef, PyFunctionRef},
1718
int::PyIntRef,
@@ -428,7 +429,11 @@ mod builtins {
428429

429430
#[pyfunction]
430431
fn aiter(iter_target: PyObjectRef, vm: &VirtualMachine) -> PyResult {
431-
vm.call_special_method(iter_target, "__aiter__", ())
432+
if iter_target.payload_is::<PyAsyncGen>() {
433+
vm.call_special_method(iter_target, "__aiter__", ())
434+
} else {
435+
Err(vm.new_type_error("wrong argument type".to_owned()))
436+
}
432437
}
433438

434439
#[pyfunction]

0 commit comments

Comments
 (0)