FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-145685: Stop the world when updating MRO of existing types by colesbury · Pull Request #145707 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 14 additions & 11 deletions Objects/typeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ clear_tp_bases(PyTypeObject *self, int final)
static inline PyObject *
lookup_tp_mro(PyTypeObject *self)
{
ASSERT_NEW_TYPE_OR_LOCKED(self);
return self->tp_mro;
}

Expand All @@ -664,8 +663,19 @@ set_tp_mro(PyTypeObject *self, PyObject *mro, int initial)
/* Other checks are done via set_tp_bases. */
_Py_SetImmortal(mro);
}
else {
PyUnstable_Object_EnableDeferredRefcount(mro);
}
}
if (!initial) {
type_lock_prevent_release();
types_stop_world();
}
self->tp_mro = mro;
if (!initial) {
types_start_world();
type_lock_allow_release();
}
}

static inline void
Expand Down Expand Up @@ -1728,18 +1738,11 @@ static PyObject *
type_get_mro(PyObject *tp, void *Py_UNUSED(closure))
{
PyTypeObject *type = PyTypeObject_CAST(tp);
PyObject *mro;

BEGIN_TYPE_LOCK();
mro = lookup_tp_mro(type);
PyObject *mro = lookup_tp_mro(type);
if (mro == NULL) {
mro = Py_None;
} else {
Py_INCREF(mro);
Py_RETURN_NONE;
}

END_TYPE_LOCK();
return mro;
return Py_NewRef(mro);
}

static PyTypeObject *find_best_base(PyObject *);
Expand Down
Loading

Back | FazBrowse Home | New Git URL