8000 gh-105020: Share tp_bases and tp_mro Between Interpreters For All Static Builtin Types by ericsnowcurrently · Pull Request #105115 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add _Py_ClearImmortal().
  • Loading branch information
ericsnowcurrently committed May 30, 2023
commit ff411b235033d927f98a8596dab990b4d875fd29
15 changes: 15 additions & 0 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(o B4F0 p)); \
op = NULL; \
} while (0)

static inline void
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
{
Expand Down
6 changes: 4 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,11 @@ clear_tp_bases(PyTypeObject *self)
{
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
if (_Py_IsMainInterpreter(_PyInterpreterState_GET())) {
if (self->tp_bases != NULL) {
if (self->tp_bases != NULL
&& PyTuple_GET_SIZE(self->tp_bases) > 0)
{
assert(_Py_IsImmortal(self->tp_bases));
// XXX Delete the tuple?
_Py_ClearImmortal(self->tp_bases);
}
}
return;
Expand Down
0