Skip to content

Conversation

@ngoldbaum
Copy link
Contributor

The Python 3.14 C API added PyUnstable_Object_IsUniquelyReferenced, which enabled checks like this to be thread-safe on the free-threaded build.

I had to update the pythoncapi-compat header to get a copy of the shim I added in python/pythoncapi-compat#149.

@ngoldbaum
Copy link
Contributor Author

Test failure looks unrelated?

Ping @indygreg could you point a way forward here?

PyObject *tmp;

if (Py_REFCNT(*obj) == 1) {
if (PyUnstable_Object_IsUniquelyReferenced(*obj)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add a note that using the Unstable API may require reinspecting this every time a new minor Python is bumped?

Other than this, LGTM

Copy link
Owner

@indygreg indygreg left a comment

Choose a reason for hiding this comment

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

This looks reasonable. Thank you!

@indygreg indygreg closed this in fc727e5 Sep 13, 2025
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