Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-128509: Addsys._is_immortal for identifying immortal objects#128510
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Lib/test/test_capi/test_immortal.py Outdated
| # CRASHES _testcapi.is_immortal(NULL) | ||
| deftest_sys(self): | ||
| self.immortal_checking(sys._is_immortal) |
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.
sys functions must be checked in test_sys.
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 intentionally moved the test fromtest_sys totest_immortal so we could re-use the test case, but I've reverted it now. Are you ok with the redundancy?
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'm ok with redundancy. test_capi can be skipped if _testcapi is missing. It's not the case for test_sys. Both tests are useful.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Python/sysmodule.c Outdated
| sys__is_immortal_impl(PyObject*module,PyObject*op) | ||
| /*[clinic end generated code: output=c2f5d6a80efb8d1a input=83733fc356c78475]*/ | ||
| { | ||
| return_Py_IsImmortal(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.
Why not using PyUnstable_IsImmortal()?
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 two are pretty similar. Would you prefer I use the unstable API?
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 would prefer to use the public unstable API, yes.
Uh oh!
There was an error while loading.Please reload this page.
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. IMO it makes sense to have a way in Python to check if an object is immortal. Otherwise, developers are confused by surprisingsys.getrefcount() values.
| } | ||
| } | ||
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.
unrelated change, I suggest to leave this empty line :-)
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.
Good catch!
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
9ba281d intopython:mainUh oh!
There was an error while loading.Please reload this page.
…cts (python#128510)Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Uh oh!
There was an error while loading.Please reload this page.
FWIW, I'm basing most of this off
sys._is_interned.📚 Documentation preview 📚:https://cpython-previews--128510.org.readthedocs.build/en/128510/library/sys.html#sys._is_immortal