Add AsyncIterator support to c-api (#8285)

This commit is contained in:
Bas Schoenmaeckers authored and GitHub committed 2026-07-15 23:41:36 +09:00
1 parent ac28fff085
commit 96fde50f75
1 file changed
+14
+14
View File
@@ -9,6 +9,15 @@ pub unsafe extern "C" fn PyIter_Check(obj: *mut PyObject) -> c_int {
with_vm(|_vm| Ok(PyIter::check(unsafe { &*obj })))
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn PyAIter_Check(obj: *mut PyObject) -> c_int {
with_vm(|vm| {
Ok(unsafe { &*obj }
.class()
.has_attr(rustpython_vm::identifier!(vm, __anext__)))
})
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn PyObject_GetIter(obj: *mut PyObject) -> *mut PyObject {
with_vm(|vm| {
@@ -17,6 +26,11 @@ pub unsafe extern "C" fn PyObject_GetIter(obj: *mut PyObject) -> *mut PyObject {
})
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn PyObject_GetAIter(obj: *mut PyObject) -> *mut PyObject {
with_vm(|vm| unsafe { &*obj }.get_aiter(vm))
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn PyIter_NextItem(iter: *mut PyObject, item: *mut *mut PyObject) -> c_int {
with_vm(|vm| {