8000 gh-128509: Add `sys._is_immortal` for identifying immortal objects by ZeroIntensity · Pull Request #128510 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128509: Add sys._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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a note to the docs and fix tests.
  • Loading branch information
ZeroIntensity committed Jan 5, 2025
commit b545f24c58ffd171843002799e29ade3cd30b578
5 changes: 5 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,11 @@ always available.
Return :const:`True` if the given object is :term:`immortal`, :const:`False`
otherwise.

.. note::

Objects that are immortal (and thus return ``True`` upon being passed to this function)
are not guaranteed to be immortal in future versions, and vice versa for mortal objects.

.. versionadded:: next

.. impl-detail::
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def test_43581(self):
# the test runs under regrtest.
self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)

@unittest.skipUnless(hasattr(sys, "_is_immortal"))
@unittest.skipUnless(hasattr(sys, "_is_immortal"), "immortality is not supported")
def test_immortal(self):
# Not extensive
known_immortals = (True, False, None, 0, ())
Expand Down
0