◐ Shell
clean mode source ↗

GH-115776: Static object are immortal, so mark them as such. by markshannon · Pull Request #117673 · python/cpython

@markshannon This change is totally valid - the reason it was not done in the first place is to avoid incompatibility with extension code.

There could be asserts/tests on exact refcount values and this change would have broken those builds/tests. You can even see it in the immoral objects PR where I had to change _testembed.c to modify the Py_REFCNT(str1) == 1 check to _Py_IsImmortal(str1)

There's an argument on whether or not having any exact refcounts checks are correct, but I didn't want to challenge it at the time. Thus, to avoid any problems with extension code and reduce the surface area of impact, I localized it to just affect the CPython build.

That said, happy to see that you are now cleaning this up!