8000 Make _PyStaticType_ClearWeakRefs thread-safe · python/cpython@6d00f51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d00f51

Browse files
committed
Make _PyStaticType_ClearWeakRefs thread-safe
1 parent 9acae59 commit 6d00f51

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Objects/weakrefobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,10 +1069,12 @@ _PyStaticType_ClearWeakRefs(PyInterpreterState *interp, PyTypeObject *type)
10691069
{
10701070
static_builtin_state *state = _PyStaticType_GetState(interp, type);
10711071
PyObject **list = _PyStaticType_GET_WEAKREFS_LISTPTR(state);
1072+
Py_BEGIN_CRITICAL_SECTION(type);
10721073
while (*list != NULL) {
10731074
/* Note that clear_weakref() pops the first ref off the type's
10741075
weaklist before clearing its wr_object and wr_callback.
10751076
That is how we're able to loop over the list. */
10761077
clear_weakref((PyWeakReference *)*list);
10771078
}
1079+
Py_END_CRITICAL_SECTION();
10781080
}

0 commit comments

Comments
 (0)
0