Skip to content

Commit c71c8be

Browse files
Replace lock with assert
1 parent ce1ed2c commit c71c8be

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Objects/typeobject.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5933,9 +5933,9 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
59335933
This returns a strong reference, and might set an exception.
59345934
'error' is set to: -1: error with exception; 0: ok */
59355935
static PyObject *
5936-
find_name_in_mro_new(PyObject *mro_dict, PyObject *name, int *error)
5936+
find_name_in_mro_new(PyTypeObject *type, PyObject *mro_dict, PyObject *name, int *error)
59375937
{
5938-
ASSERT_TYPE_LOCK_HELD();
5938+
ASSERT_NEW_TYPE_OR_LOCKED(type);
59395939

59405940
PyObject *res = NULL;
59415941
if (PyDict_GetItemRef(mro_dict, name, &res) < 0) {
@@ -11539,7 +11539,7 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p,
1153911539
if (mro_dict == NULL) {
1154011540
descr = find_name_in_mro(type, p->name_strobj, &error);
1154111541
} else {
11542-
descr = find_name_in_mro_new(mro_dict, p->name_strobj, &error);
11542+
descr = find_name_in_mro_new(type, mro_dict, p->name_strobj, &error);
1154311543
}
1154411544
if (descr == NULL) {
1154511545
if (error == -1) {
@@ -11724,7 +11724,7 @@ fixup_slot_dispatchers(PyTypeObject *type)
1172411724
// This lock isn't strictly necessary because the type has not been
1172511725
// exposed to anyone else yet, but update_ont_slot calls find_name_in_mro
1172611726
// where we'd like to assert that the type is locked.
11727-
BEGIN_TYPE_LOCK();
11727+
ASSERT_NEW_TYPE_OR_LOCKED(type);
1172811728

1172911729
PyObject *mro = Py_NewRef(lookup_tp_mro(type));
1173011730

@@ -11767,7 +11767,6 @@ fixup_slot_dispatchers(PyTypeObject *type)
1176711767
Py_XDECREF(mro_dict);
1176811768
Py_DECREF(mro);
1176911769

11770-
END_TYPE_LOCK();
1177111770
return res;
1177211771
}
1177311772

0 commit comments

Comments
 (0)