diff options
author | Peter Bierma <zintensitydev@gmail.com> | 2025-01-31 10:27:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-31 15:27:08 +0000 |
commit | 9ba281d871c4df3a3ac4cb7896d24ba0d42751a3 (patch) | |
tree | ba9d4aa78ce4f2f92430e577bd230d69b27b891e /Python/sysmodule.c | |
parent | 60a85415aeb5a8be54b3c412d19a7444bf5ac757 (diff) | |
download | cpython-9ba281d871c4df3a3ac4cb7896d24ba0d42751a3.tar.gz cpython-9ba281d871c4df3a3ac4cb7896d24ba0d42751a3.zip |
gh-128509: Add `sys._is_immortal` for identifying immortal objects (#128510)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 11b96c8455d..d5cb448eb61 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -972,6 +972,23 @@ sys__is_interned_impl(PyObject *module, PyObject *string) return PyUnicode_CHECK_INTERNED(string); } +/*[clinic input] +sys._is_immortal -> bool + + op: object + / + +Return True if the given object is "immortal" per PEP 683. + +This function should be used for specialized purposes only. +[clinic start generated code]*/ + +static int +sys__is_immortal_impl(PyObject *module, PyObject *op) +/*[clinic end generated code: output=c2f5d6a80efb8d1a input=4609c9bf5481db76]*/ +{ + return PyUnstable_IsImmortal(op); +} /* * Cached interned string objects used for calling the profile and @@ -2588,6 +2605,7 @@ static PyMethodDef sys_methods[] = { SYS__GETFRAMEMODULENAME_METHODDEF SYS_GETWINDOWSVERSION_METHODDEF SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF + SYS__IS_IMMORTAL_METHODDEF SYS_INTERN_METHODDEF SYS__IS_INTERNED_METHODDEF SYS_IS_FINALIZING_METHODDEF |