Missing PySendResult
return type for pyo3::ffi::PyIter_Send
#4727
Open
Description
Bug Description
I wanted to use PyIter_Send
function for a generator and I can't have the function result:
https://github.com/PyO3/pyo3/blob/v0.23.1/pyo3-ffi/src/abstract_.rs#L123
Steps to Reproduce
An example which should work:
use pyo3::prelude::*;
use pyo3::ffi as pyo3_ffi;
let generator_module = PyModule::from_code(
py,
pyo3_ffi::c_str!(
r#"
def gen():
val = yield 1
yield val
"#
),
pyo3_ffi::c_str!("generator_module.py"),
pyo3_ffi::c_str!("generator_module"),
)?;
let generator = generator_module.getattr("gen")?.call0()?;
unsafe {
let presult: *mut pyo3_ffi::PyObject = std::ptr::null_mut();
match pyo3_ffi::PyIter_Send(generator.as_ptr(), py.None().as_ptr(), &mut presult) {
pyo3_ffi::PySendResult::PYGEN_RETURN => todo!(),
pyo3_ffi::PySendResult::PYGEN_NEXT => todo!(),
pyo3_ffi::PySendResult::PYGEN_ERROR => todo!(),
}
}
Backtrace
No response
Your operating system and version
Manjaro Linux 24.1
Your Python version (python --version
)
Python 3.11.10
Your Rust version (rustc --version
)
rustc 1.82.0 (f6e511eec 2024-10-15)
Your PyO3 version
0.23.1
How did you install python? Did you use a virtualenv?
pyenv
Additional Info
No response