-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-143300: implement PyUnstable_SetImmortal
#144543
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -801,3 +801,19 @@ Object Protocol | |||||
| cannot fail. | ||||||
| .. versionadded:: 3.14 | ||||||
| .. c:function:: int PyUnstable_SetImmortal(PyObject *obj) | ||||||
| Marks the object op immortal. The argument should be uniquely referenced by | ||||||
| the calling thread. | ||||||
| This is a one-way process: objects can only be made immortal, they cannot be | ||||||
| made mortal once again. Immortal objects do not participate in reference counting | ||||||
| and will never be garbage collected. | ||||||
| This function is intended to be used soon after op is created, by the code that | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| creates it, such as in the object's tp_new slot. | ||||||
| Returns 1 if the object was made immortal and returns 0 if it was not. | ||||||
| This function cannot fail. | ||||||
| .. versionadded:: next | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2790,6 +2790,14 @@ PyUnstable_EnableTryIncRef(PyObject *op) | |
| #endif | ||
| } | ||
|
|
||
| int | ||
| PyUnstable_SetImmortal(PyObject *op) | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should there maybe be a call to |
||
| assert(op != NULL); | ||
| _Py_SetImmortal(op); | ||
| return 1; | ||
| } | ||
|
|
||
| void | ||
| _Py_ResurrectReference(PyObject *op) | ||
| { | ||
|
|
||
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.
?