-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyo3(get, set)
attribute not found when using cfg_attr
#1003
Comments
This is basically a duplicate of #780. |
Based on #780 (comment) I wonder if we can resolve this by changing This is kind of a hack, though, so I wonder if really we should be asking the compiler team if it's reasonable to expand all |
Looks like the compiler team may indeed be doing that rust-lang/rust#83824 |
Is there a suggested workaround for this issue until that compiler feature lands? Thanks for the help! |
You can manually implement getters/setters, and guard that block with a cfg:
I've had to do this for structs with hundreds of fields - not fun. Note that you may need to apply |
@mejrs |
It is listed at https://pyo3.rs/v0.18.3/class.html#customizing-the-class I'm not sure where else this information should be. Where were you looking for it? |
oh sorry, I thought the "pyo3(get,set) doesn't work with cfg_attr" problem was mentioned in the FAQs - if it is included in the future I'd recommend a sentence that suggests |
For those stumbling upon this, here is a super explicit example with
|
This reverts commit 9dd7f90. See: PyO3/pyo3#1003
🐛 Bug Reports
When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.
🌍 Environment
Arch Linux x86_64 5.7.4-arch1-1
Python 3.8.3
pacman
rustc --version
):rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)
0.10.1
version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
: No💥 Reproducing
Please provide a minimal working example. This means both the Rust code and the Python.
This compiles
However, this doesn't
Because it can't find the
pyo3
attributePlease also write what exact flags are required to reproduce your results.
The text was updated successfully, but these errors were encountered: