Async pymethod
with receiver can not pass any other arguments
#4005
Labels
pymethod
with receiver can not pass any other arguments
#4005
Bug Description
When I tried to introduce argument other than receiver(i.e. &self/&mut self) to async method, I found that the code(see
Steps to Reproduce
) would not compile(see theBacktrace
part), even though the parameter was actuallySend + 'static
itself.I'm not sure if this is by design, but it looks strange to me.
I'm new to the PyO3's code base, but I took a closer look.
The expanded code for the async block is:
This move the
output
(Option<pyo3::Borrowed<', ', pyo3::PyAny>> here) to async block and therefore does not satisfy the requirements ofSend
.I think we should evaluate the arg before move it, like:
If this idea make sense, I can come up with a PR then.
Steps to Reproduce
Backtrace
Your operating system and version
MacOs 14.3.1
Your Python version (
python --version
)3.11
Your Rust version (
rustc --version
)rustc 1.76.0 (07dca489a 2024-02-04)
Your PyO3 version
0.21.0
How did you install python? Did you use a virtualenv?
By virtualenv
Additional Info
No response
The text was updated successfully, but these errors were encountered: