-
Notifications
You must be signed in to change notification settings - Fork 784
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
update object.h definitions for Python 3.12 #3335
Conversation
17c5a40
to
bc6ba9f
Compare
20dd7c1
to
d813d48
Compare
d813d48
to
ea4cf62
Compare
Ok, looks like we're there 🎉 I changed tests which interact with reference counting to use |
I'd quite like to merge this soon so that I can proceed with the patch release. The following summarises the diff, to help with reviewing:
I appreciate this is quite a meaty patch 😢 |
pyo3-ffi/src/object.rs
Outdated
#[cfg(Py_3_12)] | ||
pub union __pyo3_object_ob_refcnt { | ||
pub ob_refcnt: Py_ssize_t, | ||
#[cfg(not(target_pointer_width = "32"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only works for target_pointer_width = "64"
and would hence would prefer that as the cfg
attribute here and above. (I don't think we can reasonably CPython on CHERI here in any case.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C header used # if SIZEOF_VOID_P > 4
, of which the closest analogy I could find was not(target_pointer_width = "32")
, disregarding 16 bits which I don't think we would try to support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think copying verbatim is not useful here and would prefer the direct formulation as the structure does not make sense for anything but 64-bit architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say that CPython is certainly not becoming less baroque.
Besides the inline questions on trying to better abstract out the differences in how the reference counts are handled, I wonder whether PyAny::get_refcnt
would have to change as this looks more like Option<isize>
then isize
conceptionally?
Pushed a commit with review corrections, I'll squash before merge. I think there is an open question for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the usage of target_point_width
.
95108e2
to
ef43731
Compare
🙏 thanks for the thorough reviewing! Changed to use |
This fixes a flaky reference counting issue observed in tests which seems to be related to the new "immortal objects" of Python 3.12.
So many changes had happened to
object.h
due to the immortal objects I felt it better to do a full reconciliation of the definitions in that file against the 3.12 header.The reference counting changes are complicated, so I'd like to see a full CI run and also add some more tests before calling this ready to merge.