Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Feb 6, 2026

Copy link
Member

@ZeroIntensity ZeroIntensity 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 we also need to document the guarantees regarding which objects may be made immortal. For example, the following results in an assertion failure:

from ctypes import pythonapi, py_object, c_int

set_immortal = pythonapi.PyUnstable_SetImmortal
set_immortal.argtypes = (py_object,)
set_immortal.restype = c_int

print(set_immortal("Hello world"))

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Looks pretty good.

Bikeshedding: Should this be named PyUnstable_Object_SetImmortal? The Py[Unstable]_ prefix is generally reserved for runtime operations (though it seems PyUnstable_TryIncRef didn't follow that rule).

@kumaraditya303
Copy link
Contributor Author

Should this be named PyUnstable_Object_SetImmortal?

I'd like to keep it aligned with PyObject_IsImmortal and avoid introducing the Object in between.

@kumaraditya303 kumaraditya303 marked this pull request as ready for review February 10, 2026 14:11
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

LGTM!

@kumaraditya303 kumaraditya303 merged commit 347d359 into python:main Feb 11, 2026
51 checks passed
@kumaraditya303 kumaraditya303 deleted the immortal branch February 11, 2026 15:29
@vstinner
Copy link
Member

Kumar also added PyUnstable_SetImmortal() function for Python 3.13 and 3.14 in pythoncapi-compat: python/pythoncapi-compat#164.

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.

5 participants