Skip to content

Commit c8ccd02

Browse files
committed
Implement atomic load and critical section in C code
1 parent 7ed6c5c commit c8ccd02

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Objects/object.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,10 +1715,16 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
17151715
dict = (PyObject *)_PyObject_GetManagedDict(obj);
17161716
}
17171717
else {
1718+
Py_BEGIN_CRITICAL_SECTION(obj);
17181719
PyObject **dictptr = _PyObject_ComputedDictPointer(obj);
17191720
if (dictptr) {
1721+
#ifdef DISABLE_GIL
1722+
dict = (PyObject *)_Py_atomic_load_ptr(dictptr);
1723+
#else
17201724
dict = *dictptr;
1725+
#endif
17211726
}
1727+
Py_END_CRITICAL_SECTION();
17221728
}
17231729
}
17241730
if (dict != NULL) {

0 commit comments

Comments
 (0)