-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-128509: Add PyUnstable_IsImmortal
for finding immortal objects
#129182
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
Changes from 13 commits
58ac265
8a64537
4b55134
6bddf33
412a42b
21cf2c4
8d20c00
831626c
422edf9
6014587
48c974c
dd19a02
99e897f
0448daf
5b949b1
d1c9b1f
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add :c:func:`PyUnstable_IsImmortal` for determining whether an object is | ||
:term:`immortal`. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -131,13 +131,22 @@ pyobject_enable_deferred_refcount(PyObject *self, PyObject *obj) | |||||||
return PyLong_FromLong(result); | ||||||||
} | ||||||||
|
||||||||
|
||||||||
static PyObject * | ||||||||
is_immortal(PyObject *self, PyObject *op) | ||||||||
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. Oh, I didn't know that |
||||||||
{ | ||||||||
return PyBool_FromLong(PyUnstable_IsImmortal(op)); | ||||||||
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
This allows to test with NULL, and check if the result is not 0 or 1. 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. I think it makes sense to crash with |
||||||||
} | ||||||||
|
||||||||
|
||||||||
static PyMethodDef test_methods[] = { | ||||||||
{"call_pyobject_print", call_pyobject_print, METH_VARARGS}, | ||||||||
{"pyobject_print_null", pyobject_print_null, METH_VARARGS}, | ||||||||
{"pyobject_print_noref_object", pyobject_print_noref_object, METH_VARARGS}, | ||||||||
{"pyobject_print_os_error", pyobject_print_os_error, METH_VARARGS}, | ||||||||
{"pyobject_clear_weakrefs_no_callbacks", pyobject_clear_weakrefs_no_callbacks, METH_O}, | ||||||||
{"pyobject_enable_deferred_refcount", pyobject_enable_deferred_refcount, METH_O}, | ||||||||
{"is_immortal", is_immortal, METH_O}, | ||||||||
{NULL}, | ||||||||
}; | ||||||||
|
||||||||
|
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.
Does
_testcapi.is_immortal(NULL)
crash? If yes, add a comment, otherwise add a test.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.
And ideally an
assert
to the implementation (as “executable documentation”).