gh-105587: Remove assertion from `_PyStaticObject_CheckRefcnt` (GH-105638)
(cherry picked from commit
6199fe3b3236748033a7ce2559aeddb5a91bbbd9)
Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
static inline void
_PyStaticObject_CheckRefcnt(PyObject *obj) {
if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) {
- _PyObject_ASSERT_FAILED_MSG(obj,
- "immortal object has less refcnt than expected "
- "_Py_IMMORTAL_REFCNT");
+ fprintf(stderr, "Immortal Object has less refcnt than expected.\n");
+ _PyObject_Dump(obj);
}
}
#endif
--- /dev/null
+The runtime can't guarantee that immortal objects will not be mutated by
+Extensions. Thus, this modifies _PyStaticObject_CheckRefcnt to warn
+instead of asserting.