|
3 | 3 |
|
4 | 4 | use crate::{ |
5 | 5 | builtins::{ |
6 | | - pystr::AsPyStr, PyBytes, PyDict, PyDictRef, PyGenericAlias, PyInt, PyList, PyStr, PyStrRef, |
7 | | - PyTuple, PyTupleRef, PyType, PyTypeRef, |
| 6 | + pystr::AsPyStr, PyAsyncGen, PyBytes, PyDict, PyDictRef, PyGenericAlias, PyInt, PyList, |
| 7 | + PyStr, PyStrRef, PyTuple, PyTupleRef, PyType, PyTypeRef, |
8 | 8 | }, |
9 | 9 | bytesinner::ByteInnerNewOptions, |
10 | 10 | common::{hash::PyHash, str::to_ascii}, |
@@ -92,6 +92,13 @@ impl PyObject { |
92 | 92 | } |
93 | 93 |
|
94 | 94 | // PyObject *PyObject_GetAIter(PyObject *o) |
| 95 | + pub fn get_aiter(&self, vm: &VirtualMachine) -> PyResult { |
| 96 | + if self.payload_is::<PyAsyncGen>() { |
| 97 | + vm.call_special_method(self, identifier!(vm, __aiter__), ()) |
| 98 | + } else { |
| 99 | + Err(vm.new_type_error("wrong argument type".to_owned())) |
| 100 | + } |
| 101 | + } |
95 | 102 |
|
96 | 103 | pub fn has_attr<'a>(&self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine) -> PyResult<bool> { |
97 | 104 | self.get_attr(attr_name, vm).map(|o| !vm.is_none(&o)) |
|
0 commit comments