Skip to content

Commit d1012c3

Browse files
committed
Lock the dict if we're not in a stop-the-world event
1 parent d63f19b commit d1012c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Objects/typeobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7568,7 +7568,11 @@ object_set_class_world_stopped(PyObject *self, PyTypeObject *newto)
75687568

75697569
assert(_PyObject_GetManagedDict(self) == dict);
75707570

7571-
if (_PyDict_DetachFromObject(dict, self) < 0) {
7571+
int err;
7572+
Py_BEGIN_CRITICAL_SECTION(dict);
7573+
err = _PyDict_DetachFromObject(dict, self);
7574+
Py_END_CRITICAL_SECTION();
7575+
if (err < 0) {
75727576
return -1;
75737577
}
75747578

0 commit comments

Comments
 (0)