mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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:
parent
26e7bbf66e
commit
7be667dfaf
6 changed files with 122 additions and 34 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue