limited pyo3
options when deriving both FromPyObject
and IntoPyObject
?
#4884
Labels
pyo3
options when deriving both FromPyObject
and IntoPyObject
?
#4884
Currently combining the derive macros for
FromPyObject
andIntoPyObject
limits the possible#[pyo3(...)]
options to the union of options supported by both macros. It would be desirable to also allow individual options when combining them.See also: #4883 (comment)
Discussed in #4883
Originally posted by baxtersa January 29, 2025
Hi all. I've been working with
FromPyObject
for values passed as arguments from python code calling into Rust, but am having trouble implementing theIntoPyObject
direction. We have a customfrom_py_with
function because one of our fields is a generic type with aconst
parameter, so we manually convert from aVec
to a fixed-size array. When adding the derivation forIntoPyObject
, we get compiler errors on thepyo3(...)
attribute sayingerror: expected 'attribute' or 'item'
. Withoutderive(IntoPyObject)
, the rest of this code compiles just fine.Here is a simplified reproduction of what I'm seeing
and the compiler error we receive
Is it possible to use
from_py_with
when also derivingIntoPyObject
? I have seen that something likeinto_py_with
is in-progress too, so maybe this is just a current limitation?I'm using
pyo3=0.23.4
.Thanks for the assistance.
The text was updated successfully, but these errors were encountered: