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

Remove Copy and Clone derives from PyObject #4434

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

ngoldbaum
Copy link
Contributor

@ngoldbaum ngoldbaum commented Aug 12, 2024

Refs #4265 #4421 (comment).

It's almost certainly not correct for someone to allocate a PyObject struct outside of the Python runtime, so we shouldn't make it easy to do so. This is also needed for the free-threading work, where PyMutex is a field in PyObject.

The changes in the datetime FFI fix "cannot move out of a raw pointer" compiler errors. It was probably a bug that these datetime interfaces were copying a PyObject struct.

This is a breaking change and I need to add a changelog entry. Do FFI breaking changes show up in the migration guide? If so, do I need to suggest anything besides removing Copy and Clone from derived types?

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

I think this is great as-is; I might write a more complete migration note for "FFI changes" as part of #4379. Thanks very much!

Hilarious to find that our datetime bindings were misusing the Copy nature of the struct. I think in practice the compiler would optimize away the full "move" here to just read the target field, but still... 🤦

@davidhewitt davidhewitt added this pull request to the merge queue Aug 12, 2024
Merged via the queue into PyO3:main with commit 0958568 Aug 12, 2024
41 of 42 checks passed
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.

3 participants