Skip to content

handle #[pyo3(from_py_with = "")] in #[setter] methods#3995

Merged
davidhewitt merged 2 commits into
PyO3:mainfrom
Icxolu:fix-3992
Mar 26, 2024
Merged

handle #[pyo3(from_py_with = "")] in #[setter] methods#3995
davidhewitt merged 2 commits into
PyO3:mainfrom
Icxolu:fix-3992

Conversation

@Icxolu

@Icxolu Icxolu commented Mar 26, 2024

Copy link
Copy Markdown
Member

Fixes #3992

Handle the #[pyo3(from_py_with = "")] attribute in #[setter] methods instead of silently ignoring it.

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

I wonder if the fact that this slipped through means that there's a bigger refactoring overdue, but I'm happy to leave that for a future PR...

})
.unwrap_or_else(|| {
quote! {
let _val = #pyo3_path::FromPyObject::extract_bound(_value.into())?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose here we probably want to check if _val is a GIL Ref, via holders.push_gil_refs_checker?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Either way, I think worthy of its own PR and newsfragment, so I'll merge this PR now.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, maybe I'll take a look at that tomorrow

@davidhewitt davidhewitt added this pull request to the merge queue Mar 26, 2024
Merged via the queue into PyO3:main with commit 35faeff Mar 26, 2024
@MarquessV

Copy link
Copy Markdown

Thanks for the quick fix @Icxolu!

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.

#[pyo3(from_py_with = "...")] causes compilation error when used in methods with the #[setter] attribute.

3 participants