gh-105020: Share tp_bases and tp_mro Between Interpreters For All Static Builtin Types (gh-105115)

In gh-103912 we added tp_bases and tp_mro to each PyInterpreterState.types.builtins entry.  However, doing so ignored the fact that both PyTypeObject fields are public API, and not documented as internal (as opposed to tp_subclasses).  We address that here by reverting back to shared objects, making them immortal in the process.
This commit is contained in:
Eric Snow 2023-05-30 18:13:35 -06:00 committed by GitHub
parent 26e7bbf66e
commit 7be667dfaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 34 deletions

View file

@ -76,6 +76,21 @@ static inline void _Py_SetImmortal(PyObject *op)
}
#define _Py_SetImmortal(op) _Py_SetImmortal(_PyObject_CAST(op))
/* _Py_ClearImmortal() should only be used during runtime finalization. */
static inline void _Py_ClearImmortal(PyObject *op)
{
if (op) {
assert(op->ob_refcnt == _Py_IMMORTAL_REFCNT);
op->ob_refcnt = 1;
Py_DECREF(op);
}
}
#define _Py_ClearImmortal(op) \
do { \
_Py_ClearImmortal(_PyObject_CAST(op)); \
op = NULL; \
} while (0)
static inline void
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
{