Skip to content
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

frompyobject: fix from_py_with ignored for transparent structs #2440

Merged
merged 1 commit into from
Jun 9, 2022

Conversation

davidhewitt
Copy link
Member

@davidhewitt davidhewitt commented Jun 8, 2022

Fixes #2396

Technically this is breaking, because previously the following enum would ignore the from_py_with annotation in the first variant. Now it will be used, so rather than only accepting positive integers the first variant will now accept anything with a __len__. So there are silent changes of behaviour.

#[derive(Debug, FromPyObject, PartialEq)]
pub enum ZapEnum {
    Zip(#[pyo3(from_py_with = "PyAny::len")] usize),
    Zap(String, #[pyo3(from_py_with = "PyAny::len")] usize),
}

However, on balance I would hope that this fixes any bugs users have rather than breaks stuff! I would defend fixing this is the correct choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

from_py_with ignored for single-attribute FromPyObject-deriving tuple-struct
1 participant